{"id":16441880,"url":"https://github.com/nil/hex-format","last_synced_at":"2025-08-15T17:07:43.846Z","repository":{"id":57263051,"uuid":"153913692","full_name":"nil/hex-format","owner":"nil","description":"Turn a string into a 6-digit hex color value.","archived":false,"fork":false,"pushed_at":"2018-11-25T13:56:26.000Z","size":29,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-09T07:48:42.816Z","etag":null,"topics":["beautify","color","converter","formatter","hex","hexadecimal"],"latest_commit_sha":null,"homepage":"","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/nil.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-10-20T14:26:06.000Z","updated_at":"2020-05-12T15:27:41.000Z","dependencies_parsed_at":"2022-09-01T04:27:35.107Z","dependency_job_id":null,"html_url":"https://github.com/nil/hex-format","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/nil/hex-format","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nil%2Fhex-format","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nil%2Fhex-format/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nil%2Fhex-format/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nil%2Fhex-format/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nil","download_url":"https://codeload.github.com/nil/hex-format/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nil%2Fhex-format/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270602454,"owners_count":24614260,"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","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["beautify","color","converter","formatter","hex","hexadecimal"],"created_at":"2024-10-11T09:15:41.073Z","updated_at":"2025-08-15T17:07:43.798Z","avatar_url":"https://github.com/nil.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hex-format\n\nTurn a string into a 6-digit hex color value.\n\nMost color inputs accept hex values, but only if they are the standard, 6-digit format. They reject possible mistakes and shorter codes, which results in a bad user experience. hex-format is written to format a given string and return a valid, 6-digit hex code ready to be used in JavaScript and CSS.\n\n[![Build status](https://travis-ci.org/nil/hex-format.svg?branch=master)](https://travis-ci.org/nil/hex-format)\n[![Dependencies status](https://img.shields.io/david/dev/nil/hex-format.svg)](https://david-dm.org/nil/hex-format)\n[![Version](https://img.shields.io/npm/v/hex-format.svg)](https://www.npmjs.com/package/hex-format)\n[![License](https://img.shields.io/npm/l/hex-format.svg)](https://github.com/nil/hex-format/blob/master/LICENSE)\n\n## Installation\n\nOpen Terminal and install the package with this command:\n\n```sh\nnpm install hex-format --save\n```\n\nThen import hex-format into any file you are planning to use it:\n\n```js\n// Node's require()\nconst Hex = require('hex-format');\n\n// ES6 imports\nimport Hex from 'hex-format';\n```\n\nFinally, call hex-format’s class. If you want to use the default options, remove `[options]`, otherwise, replace it with an object. Find all the available options in [its section](#options).\n\n```js\nconst hex = new Hex([options]);\n```\n\nNow you are ready to use hex-format.\n\n\n## API\n\n### `.format`\n\nReturns `false` or a valid, 6-digit hex color code.\n\n```js\nhex.format('154') //=\u003e #115544\nhex.format('#a9') //=\u003e #A9A9A9\nhex.format('#xx9') //=\u003e false\n```\n\n## Options\n\nThis options allow you to configure the behavior of a string when it its formatted.\n\n### Methods\n\nReplace the default format algorithm with another predefined one.\n\n**key**: number of valid characters (7 if there are more than 6).\n\n| Value      | Description                               | Valid for        | Example             |\n|------------|-------------------------------------------|------------------|---------------------|\n| `invalid`  | Always returns false                      | 1, 2, 3, 4, 5, 7 | 3A =\u003e false         |\n| `altern`   | Doubles or triples the characters         | 1, 2, 3, 4, 5    | B1C =\u003e #BB11CC      |\n| `repeat`   | Repeat the characters until the end       | 1, 2, 4, 5, 6    | 5EF1 =\u003e #55EEFF     |\n| `fill`     | Fill the extra space with 0               | 1, 2, 4, 5, 6    | 2D =\u003e #2D0000       |\n| `equal`    | The result is the same as the given value | 6                | 6E7F2D =\u003e #6E7F2D   |\n| `truncate` | Takes only the 6 first characters         | 6, 7             | E8F1C6A5 =\u003e #E8F1C6 |\n\nExample:\n\n```js\nconst hex = Hex({\n  1: 'repeat',\n  4: 'fill'\n  7: 'invalid'\n})\n```\n\n## About\n\n### Contributing\n\nIf you find any issue, have troubles figuring out something or want to suggest a change, please [open an issue](https://github.com/nil/hex-format/issues/new) or [make a pull request](https://github.com/nil/hex-format/compare).\n\u003c/details\u003e\n\n### Tests\nTo run the tests, first install the dev dependencies and then run the `test` command:\n\n```sh\nnpm install -d \u0026\u0026 npm test\n```\n\n### License\n© 2018 [Nil Vila](https://twitter.com/nilvilam). Released under the [MIT License](https://github.com/nil/hex-format/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnil%2Fhex-format","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnil%2Fhex-format","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnil%2Fhex-format/lists"}