from Hacker News

Show HN: A color name API that maps hex to the closest human-readable name

by meodai on 6/19/25, 10:40 AM with 52 comments

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

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 [2] XKCD color survey results: https://xkcd.com/color/rgb/

  • by airstrike on 6/21/25, 12:59 PM

    Really 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?

  • by kiru_io on 6/21/25, 8:46 AM

    Wow, 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/ [1] https://x.com/wifeofnoob/status/1935788167086436375

  • by aaviator42 on 6/22/25, 3:31 AM

    Those who find this interesting may find my tool helpful, a color picker that only has named HTML colors: https://aavi.xyz/proj/colors
  • by Theodores on 6/21/25, 12:02 PM

    I 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?

  • by ZoomZoomZoom on 6/21/25, 2:10 PM

    There's also https://colornames.org/ - crowdsourced attempt at naming all the colours. Currently at 25% (4215221).
  • by kotaKat on 6/21/25, 9:43 AM

    Curious if you could run it against the big old list of HN topcolors...

    https://news.ycombinator.com/topcolors

  • by tillcarlos on 6/21/25, 2:06 PM

    Is 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.

  • by esperent on 6/21/25, 12:36 PM

    I 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.

  • by magic_hamster on 6/21/25, 8:58 AM

    This 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?
  • by Gys on 6/21/25, 7:51 AM

    Beautifully 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.

  • by nkrisc on 6/21/25, 10:40 AM

    You have to scroll all the way to the top to turn off the distracting shapes falling, at least on mobile.
  • by JdeBP on 6/21/25, 4:21 PM

    I 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. (-:
  • by kuehle on 6/21/25, 4:29 PM

    Makes me wonder which area of the Color space has the lowest resolution. As in “this name covers the most hex codes”.
  • by rossant on 6/21/25, 7:45 AM

    What distance metrics do you use?