{"id":26613474,"url":"https://github.com/alecperkins/afid","last_synced_at":"2026-02-16T02:02:03.003Z","repository":{"id":65520196,"uuid":"593826939","full_name":"alecperkins/afid","owner":"alecperkins","description":"Human-friendly identifiers.","archived":false,"fork":false,"pushed_at":"2025-02-16T01:30:26.000Z","size":97,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T00:38:56.155Z","etag":null,"topics":["human-friendly","identifiers","javascript"],"latest_commit_sha":null,"homepage":"https://alecperkins.net/afid","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alecperkins.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-26T23:18:37.000Z","updated_at":"2025-02-16T01:28:03.000Z","dependencies_parsed_at":"2023-02-15T04:16:49.824Z","dependency_job_id":null,"html_url":"https://github.com/alecperkins/afid","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecperkins%2Fafid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecperkins%2Fafid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecperkins%2Fafid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecperkins%2Fafid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecperkins","download_url":"https://codeload.github.com/alecperkins/afid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248148219,"owners_count":21055547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["human-friendly","identifiers","javascript"],"created_at":"2025-03-24T04:25:10.171Z","updated_at":"2026-02-16T02:02:02.907Z","avatar_url":"https://github.com/alecperkins.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# afid: AFfordance’d IDentifiers\n\n[![npm package](https://img.shields.io/npm/v/afid)](https://www.npmjs.com/package/afid) [![typescript](https://img.shields.io/npm/types/afid)]() [![MIT license](https://img.shields.io/npm/l/afid)](https://github.com/alecperkins/afid/blob/main/LICENSE) [![test status](https://github.com/alecperkins/afid/actions/workflows/test.yml/badge.svg)](https://github.com/alecperkins/afid/actions/workflows/test.yml)\n\n`afid()` generates small random strings intended to be used as identifiers that are human friendly, with affordances for reading the identifier in a list or exchanging it verbally. The identifiers are short, omit certain characters that are easily confused, and avoid forming words (no [problem #3,735,928,559](https://3735928559.xyz)).\n\nThey are useful for situations that typically use sequential numbers but in scenarios where that is not desired. Use cases include: invoice numbers that don’t reveal the count of invoices; transaction reference keys. They are especially helpful for sets that, when sorted by this identifier, benefit from visual distinction and quick random access; ie at smaller scales each id will quickly and significantly differ from its neighbors when sorted. At the default length, the number of possible ids is well into the billions. This is suitable for many usecases but not for large or distributed data sets.\n\n\u003e Note: `afid` does not use a secure random generator, and the identifiers are intentionally very short. Do not assume they are globally unique or unguessable! Also note that they are not lexigraphically sortable. See [Alternatives](#alternatives) below for other options if your priorities differ.\n\n\n## Afid anatomy\n\nA sample of some ids:\n\n```\nJU7894XR\nK89RD234\nY3724QR6\n3638J378\n```\n\nShorter or longer ids can be generated, though beyond 10 or 12 characters they lose ease-of-use:\n\n```\n2U787\nGM932AE2\n46RF3DR434R\nAK26VG8V8469\nH7489DU4786V\nPW2324HW3937FX8A9K8NK32T\n3464HM9473WR8794XK2829GN\n```\n\nThe ids can have some enhancements:\n\n```\n9874-DA89\nU49-47V-G49\n4347.ED37.2HR8.429Q\nPRE-86XG89QJ\n9492W427-POST\n```\n\n### Afid Characteristics\n\n- short, default length is 8 characters\n- omits certain ambiguous characters (`I`,`1`,`O`,`0`,`Z`,`B`)\n  - `L` is omitted since it looks like 1 if the id is displayed in lowercase\n- never has more than two letters or four numbers in a row\n  - avoids forming words\n  - uses the letters to punctuate the number groups\n- encodes no information in the body of the id\n- characters can be grouped for easier reading\n- problematic patterns like exponential notation are avoided\n\n## Installation\n\n`npm install --save afid`\n\nand include as a JavaScript or TypeScript module (types included):\n\n```typescript\nimport afid from 'afid';\n```\n\n…or a CommonJS module:\n\n```javascript\nconst afid = require('afid');\n```\n\nOr use the file directly in markup via the [unpkg CDN](https://unpkg.com/):\n\n```html\n\u003cscript src=\"https://unpkg.com/afid\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  const id = window.afid();\n  …\n\u003c/script\u003e\n```\n\n\n## Usage\n\nTry an [interactive example](https://alecperkins.net/afid)\nor [live code](https://runkit.com/embed/4y1qvehpspvc).\n\n### Basic use\n\nCall to get an eight character long identifier.\n\n```javascript\n\u003e afid()\n'CJ6376A8'\n```\n\n### Vary the length\n\nOptionally specify a different length. _Keep in mind: the number of possible identifiers decreases rapidly as it gets shorter; the usefulness for humans gets worse as it gets longer._\n\n```javascript\n\u003e afid(12)\n'K4XH984DE486'\n\u003e afid(6)\n'27UV3K'\n```\n\nAlternatively as part of the options:\n```javascript\n\u003e afid({ length: 6 })\n'MP3696'\n```\n\n### Set a prefix or suffix\n\n```javascript\n\u003e afid({ prefix: \"CLIENT-\" })\n'CLIENT-9KW42HU2'\n\u003e afid({ suffix: \"WEB\" })\n'G3QT9D2KWEB'\n```\n\n### Segment the id\n\n```javascript\n\u003e afid({ segments: 2 })\n'RA24-64UK'\n```\n\nOptionally change the delimiter:\n\n```javascript\n\u003e afid({ segments: 2, separator: \"_\" })\n'2848_Y968'\n```\n\nCombine with the other options:\n\n```javascript\n\u003e afid({ segments: 2, prefix: \"WEB-\" })\n'WEB-CH36-F4MU'\n\u003e afid({ segments: 3, length: 9, suffix: \"-WEB\", separator: \".\" })\n'NJ2.893.WH6-WEB'\n```\n\n\n## Alternatives\n\nThere are many great [ID generation schemes](https://github.com/grantcarthew/awesome-unique-id) with different priorization of security or uniqueness.\n\n\n## Author\n\nAlec Perkins, https://alecperkins.net\n\n\n## License\n\nThis package is licensed under the [MIT License](https://opensource.org/licenses/MIT).\n\nSee `./LICENSE` for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecperkins%2Fafid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecperkins%2Fafid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecperkins%2Fafid/lists"}