5 ms·
Show HN: A color name API that maps hex to the closest human-readable name
I built this API to return the closest named color for any hex value—using curated lists like my own [1], XKCD [2], and others.
I made it from scratch without Express or any frameworks because:
- I’m a frontend/interaction dev and wanted to learn how to build an API from the ground up.
- Existing APIs didn’t guarantee unique names per color—mine does.
- It also supports WebSocket updates, gzip responses, and multiple name sets.
I’ve been collecting color names for over 10 years [1]. With ~30,000 entries, bundling them into every color-related project became excessive. This API keeps things lightweight—for me and hopefully for others too.
GitHub: https://github.com/meodai/color-name-api https://github.com/meodai/color-name-api
Would love feedback on naming logic, accuracy, performance, or backend best practices I might’ve missed.
[1] Large Color Name List: https://github.com/meodai/color-names https://github.com/meodai/color-names
[2] XKCD color survey results: https://xkcd.com/color/rgb/ https://xkcd.com/color/rgb/
- JdeBP 1y agoI noticed the other day that the colour picker in Microsoft Termimal now gives the Web Colour names as one moves the mouse pointer around. I don't know how long it has been doing that without my noticing. I don't change colours all of that often. (-:
- kuehle 1y agoMakes me wonder which area of the Color space has the lowest resolution. As in “this name covers the most hex codes”.
- meodai 1y agoWonder no longer: https://codepen.io/meodai/full/zdgXJj/ https://codepen.io/meodai/full/zdgXJj/ Color distribution of Color-Names in various color models
- aaviator42 1y agoThose who find this interesting may find my tool helpful, a color picker that only has named HTML colors: https://aavi.xyz/proj/colors https://aavi.xyz/proj/colors
- rossant 1y agoWhat distance metrics do you use?
- meodai 1y agoCIEDE2000 ΔE: https://github.com/meodai/color-name-api/blob/main/src/closestColor.js#L15C43-L15C62 https://github.com/meodai/color-name-api/blob/main/src/close...
- meodai 1y agoPS: I've added a section to the Readme: https://github.com/meodai/color-name-api?tab=readme-ov-file#distance-function--color-matching-algorithm https://github.com/meodai/color-name-api?tab=readme-ov-file#...
- Gys 1y agoBeautifully made! But I struggle a little for thinking of use cases? Maybe add some to the readme. Also, I think adding a kind of ‘main color’ would be useful. For example ‘shore’ being in the category ‘blue’ or maybe even ‘light blue’. Because for ‘shore’ itself I personally would associate with sand and maybe yellow.
- meodai 1y agoOh I mostly use it for my own apps – it just feels more human-readable than hex codes. But yeah, you're right, I should add some example use cases to the readme! Like here: https://farbvelo.elastiq.ch/ https://farbvelo.elastiq.ch/ or https://meodai.github.io/poline/ https://meodai.github.io/poline/ Thanks a lot for the feedback, I really appreciate it!
- kiru_io 1y agoWow, pretty cool to see the color-names project here. I made a simple color guessing website a few years ago [0] using your library. I almost forgot it till someone reminds how they enjoyed it ([1]). [0] https://colorguesser.com/ https://colorguesser.com/ [1] https://x.com/wifeofnoob/status/1935788167086436375 https://x.com/wifeofnoob/status/1935788167086436375
- remram 1y agoFun! If I may make one suggestion, could you please show the color I picked next to the real one once it is revealed? edit: I get the same 5 colors every time?
- kiru_io 1y ago> I get the same 5 colors every time? That's probably a bug. > Fun! If I may make one suggestion, could you please show the color I picked next to the real one once it is revealed? The color of the color-name changes to what you picked.
- meodai 1y agonice its very addicting :D
- johnisgood 1y agoGuess the Color Lilac Rose Your score 81/100 First try! My final score was 286/500 :( At any rate, it keeps using the same colors, so this needs to be improved.
- brulard 1y agoAnd the scoring is quite generous. For the coupe color I picked vibrant red, correct was some steel gray and I got 60/100 points
- johnisgood 1y ago
- magic_hamster 1y agoThis is nicely done, but can you please explain why you need this? What is the use of the color names when you already know the actual color value and can use it?
- auscompgeek 1y agoThis can be useful for accessibility. For example you might have a colour palette that users can add to, but the colours are only stored as hex codes. Giving a screen reader user just RGB values isn't as helpful as providing a name alongside it.
- meodai 1y agoThanks! Good question – it's mostly about readability and communication. Hex codes are precise but not intuitive. Names give context, like saying “salmon” instead of #fa8072. That’s helpful in design tools, UI previews, generative art, or even debugging. Also, the API works the other way around too – you can search by name to get the matching color: https://api.color.pizza/v1/docs/#api-Default-getColorNames https://api.color.pizza/v1/docs/#api-Default-getColorNames. I did not add it to the website yet, because I don't have good UI ideas for it yet.
- chownie 1y agoN=1 but I'm colourblind and frequently I need to talk to someone about a UI colour while not having any idea what the colour is called, this kind of thing is useful for me.
- kotaKat 1y agoCurious if you could run it against the big old list of HN topcolors... https://news.ycombinator.com/topcolors https://news.ycombinator.com/topcolors
- meodai 1y agoI just did, using `npx palette-aldente hn-colors.yml --formats name --namelist bestOf`: https://codepen.io/meodai/pen/ByNqbKE https://codepen.io/meodai/pen/ByNqbKE
- bargainbin 1y ago"Safety Orange" is quite apt!
- jen729w 1y agoI've based my entire colour palette on a tweak of international orange. A delightful colour. (I went with #f04c00.) https://en.wikipedia.org/wiki/International_orange https://en.wikipedia.org/wiki/International_orange
- h1fra 1y agowhat's the story behind this page?
- nkrisc 1y agoYou have to scroll all the way to the top to turn off the distracting shapes falling, at least on mobile.
- meodai 1y agoyes! but I could add a second button at the footer. (it also respects the reduced motion flag, if you set it in your OS)
- Theodores 1y agoI fully approve of this app. My use case is CSS, more specifically SVG. I put SVG in custom properties for things like icons, then use them as pseudo elements, thereby keeping decoration out of the HTML and avoiding downloads for SVG specified in CSS. My SVG is always human readable and simple. The slight problem with this is that I don't like having to escape the '#' character for colours. I prefer the nearest name, e.g. 'Chocolate' (which is orange). Hence I have bookmarked this page. One observation, I have now moved to oklch for everything else. I only do named colours and oklch, hex codes have gone the way of CMYK for me. Are there any plans to make this tool oklch-friendly?
- meodai 1y agoThanks for the feedback. For now you would have to do the conversion yourself, but I plan to store the names in a more absolute format like xyz…
- esperent 1y agoI like the falling bricks effect although it's quite janky on Brave on Android. I think it would be effective on the landing page to have a form where I can enter a hex code and get the color name. I've recently tried a couple of web apps like this to get makes for my brand colors.
- airstrike 1y agoReally nice idea. I've thought about building something similar but it's not a core feature of my product so I keep postponing it. I do have to ask, though. Why would I ever want to resolve a color name as a network request instead of calling a function?
- Sharlin 1y agoEverything is a microservice now!
- meodai 1y agoBecause a) I keep adding names and b) the list weights over 1mb https://github.com/meodai/color-names https://github.com/meodai/color-names
- airstrike 1y agoI'd definitely prefer to add 1MB to my binary than to make a remote API call, and I can always bump the version if I want the latest and greatest names.
- tillcarlos 1y agoIs your name Mèo Dài - Longcat in Vietnamese? :) Cool project! I wonder what commercial use cases come from it. On the My First Million podcast they talked a about a company selling color predictions to brands for multiple six figures. Maybe you can find correlations and predictions in the data one day.
- meodai 1y agonước đái I use it for all kinds of color generators.
- ZoomZoomZoom 1y agoThere's also https://colornames.org/ https://colornames.org/ - crowdsourced attempt at naming all the colours. Currently at 25% (4215221).
- meodai 1y agoUnfortunately most of the names are pretty bad.
- b0a04gl 1y ago[dead]