devkult_
tools26converters34
home/convert/kebab-to-snake

Convert kebab-case to snake_case

URL slugs and CSS class names can't be used directly as Python variables or SQL columns — hyphens aren't legal in those identifiers. This converter swaps the hyphens for underscores, turning kebab-case into valid snake_case line by line.

Example · kebab-casesnake_case
kebab-case input
user-name
created-at
profile-image-url
api-key
snake_case output
user_name
created_at
profile_image_url
api_key

Try it with your own data

Loading tool…

How to convert kebab-case to snake_case

  1. Split the identifier on each hyphen (user-name → user, name).
  2. Lowercase every word.
  3. Join the words with underscores.

Frequently asked questions

Why can't I use hyphens in Python or SQL identifiers?

In Python, user-name parses as user minus name. In SQL, a hyphenated identifier needs constant quoting. Underscores avoid both problems, which is why snake_case is the convention.

Does this change capitalization?

Everything is lowercased, which is what snake_case expects. If you need SCREAMING_SNAKE_CASE for constants, uppercase the result.

How does the converter know where words start and end?

It splits on separators (underscores, hyphens, spaces) and on lowercase-to-uppercase boundaries, keeping acronym runs together — so HTTPServerError splits into HTTP, Server, Error regardless of the input convention.

Can I convert many identifiers at once?

Yes — put one identifier or phrase per line and every output format converts the whole list, ready to copy as a block.

Related converters