Text case converter and slugify
Convert text to camelCase, snake_case, kebab-case, Title Case and more, or turn a title into a URL slug with accents handled.
Code examples
Copy and paste these into your own project. Each one uses only the language's standard library, so there is nothing to install.
const text = 'Héllo wereld, één voorbeeld!'
const slug = text
.normalize('NFD')
.replace(/\p{M}/gu, '')
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-+|-+$/g, '')
console.log(slug)What it does
Converts text between writing styles: camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, Title Case, Sentence case, lowercase and UPPERCASE. It can also turn a title into a URL slug, with accents stripped and letters like ß and ø written in ASCII.
How to use it
- Type or paste text, one item per line, or drop a text file.
- Pick a style. For a URL slug you can choose how umlauts are spelled (German writes ä as ae, Nordic writes å as aa) and which separator joins the words.
- Copy or download the result. Turn off Convert each line on its own to treat the whole text as one piece.
Examples
Different styles for the same words:
getUserById becomes get_user_by_id in snake_case, GET_USER_BY_ID in CONSTANT_CASE and get-user-by-id in kebab-case. Crème brûlée & Straße becomes the slug creme-brulee-strasse.
Good to know
- Words are found at spaces, punctuation, underscores, hyphens and between a lowercase letter and a capital.
HTTPServersplits intoHTTPandServer. - A slug keeps lowercase letters and digits only. Letters outside the Latin alphabet, such as Japanese, are dropped.
- lowercase and UPPERCASE change the case of the text as it is, keeping the spaces and punctuation.
- Case rules follow the Unicode standard and are not specific to one language; Turkish dotted and dotless i are not treated specially.
How are words found?
The text is split into words at spaces, punctuation, underscores and hyphens, and where a lowercase letter meets a capital: userProfile becomes user and Profile. A run of capitals followed by a word, as in HTTPServer, splits into HTTP and Server, and numbers count as words of their own.
Frequently asked questions
What does a URL slug look like?
A slug is the readable part of a web address: lowercase letters and digits joined by hyphens, such as hello-world. Accents are stripped (é becomes e) and letters like ß and ø get an ASCII form, so the result is safe in any URL.
How are German and Nordic letters handled?
By default an accent is just dropped, so ü becomes u. Choose German to write ä, ö and ü as ae, oe and ue, or Nordic to write å as aa and ø as oe, which is how those languages spell them without the letter.
Does this tool send my text anywhere?
No. Everything happens in your browser. What you type is never sent to our servers.