Convert text to snake_case underscore_case Free Online Secure
Paste a line and read it back in snake_case. The whole of it happens in your browser — nothing you type is sent anywhere, and the rules follow the language of this page rather than English.
Write it differently
Nothing uploaded
The same line in all seven writings
| Writing | The same line, written that way |
|---|---|
| uppercase | CRÈME BRÛLÉE FOR 2 — STRASSE 17, FOOBAR |
| lowercase | crème brûlée for 2 — straße 17, foobar |
| Title Case | Crème Brûlée For 2 — Straße 17, Foobar |
| snake_case | crème_brûlée_for_2_straße_17_foo_bar |
| kebab-case | crème-brûlée-for-2-straße-17-foo-bar |
| camelCase | crèmeBrûléeFor2Straße17FooBar |
| a URL slug | creme-brulee-for-2-strasse-17-foobar |
Where these forms come from
Capital and small letters were once two different alphabets. The capitals are Roman, cut into stone with a chisel; the small letters descend from the Carolingian minuscule, shaped by a pen moving quickly across parchment. Printers kept the two in separate trays — the upper case and the lower case — and the names stuck long after the trays were gone. The programming forms are much younger and were invented to solve one problem: a name cannot contain a space. snake_case came out of early C, camelCase out of Smalltalk, kebab-case out of Lisp, and the URL slug out of the need to put a human title into an address where spaces and accents are not allowed.
Where you meet them
Title case belongs to headings and book titles; sentence case to almost everything else, and increasingly to interfaces, because it reads faster. snake_case names database columns and Python variables; camelCase names JavaScript variables and Java methods; kebab-case names CSS classes and file names in web projects. The slug is what turns an article's headline into the last part of its address, and it is the one conversion here that search engines read.
Questions people ask
Why does uppercasing sometimes change the number of letters?
Because case is a property of a language, not of a character. German ß becomes SS in capitals, so one letter becomes two. Turkish has a dotted and a dotless i, and uppercasing i gives İ rather than I — getting this wrong turns a Turkish word into a different one. The conversions here follow the rules of the page's own language, which is why the same input can give different results on the Turkish page than on the English one.
Why does the slug remove accents and punctuation?
Because an address has to survive being copied into a message, printed on paper and typed back in by hand. Accented letters are legal in a modern URL but get percent-encoded when copied, turning a readable address into a line of symbols. Stripping them down to plain letters, digits and hyphens keeps the address readable, shareable and identical everywhere it appears.
Is the answer exact?
Where both units are defined in terms of one another by whole numbers, yes — the page says so above the figure, and the only rounding is in how many digits are shown. Where the ratio has no finite decimal, the page shows twelve significant digits and says the relation is approximate rather than pretending otherwise.
Does anything I type leave my device?
No. The arithmetic runs in your browser; nothing is uploaded and there is no server to upload it to. Load the page once and it keeps working with the network switched off.
Why you convert text to snake_case
A programmer cannot name a variable annual report total, because a name cannot contain a space. A database column cannot be called Customer First Name. A file called Final Draft (2).docx will, sooner or later, annoy a script. Somewhere along the line the human phrase has to become a single word, and the form that a great many communities settled on is snake_case: all the letters small, the words joined by underscores, annual_report_total, customer_first_name, final_draft_2. To convert text to snake_case is to take any phrase, in any state, and turn it into that form in one step.
Paste a line and read it back in snake_case. The conversion happens in your browser, nothing you type is sent anywhere, and the rules follow the language of this page and not English. It cuts the line into words, lowercases them and joins them with underscores. A line that is already written in camelCase is cut at its capitals too, so fooBar becomes foo_bar. Below you will find exactly what that means, what is dropped, how the page treats the awkward letters of different languages, where snake_case is the convention and where it is not, and the traps that catch people who convert text to snake_case in a hurry.
What the conversion does
Cut, lowercase, join
The page first cuts the line into words. It then lowercases each one and joins them with underscores. The line Crème brûlée for 2 — straße 17, fooBar comes back as crème_brûlée_for_2_straße_17_foo_bar. The accents are kept, the numbers stay as words of their own, the dash and the comma are gone, and fooBar has been cut in two, because the capital inside it marks a boundary.
Where the cuts fall
A word boundary is a space, a punctuation mark, a dash, a symbol or a change from small letter to capital inside a word. So the phrase customerFirstName, the phrase Customer First Name and the phrase customer-first-name all become customer_first_name. That is the practical strength of the conversion: it accepts almost any starting point and always arrives at the same place.
Copying the result
A button beside the result copies it to the clipboard. Paste it into the editor, the schema or the file dialog where the name is needed.
What the conversion does not do
It does not keep punctuation
Commas, dots and dashes are boundaries between words, not characters to carry over. That is what you want for a file name or a database column, and not what you want for prose. If you run a sentence through the page, it comes back as a name, not as a sentence, and the original punctuation is gone.
It does not remove accents
The line keeps its accented letters: crème_brûlée. Many systems accept them, but some do not, and a name that contains them may cause trouble in older tools. If you need plain letters, use the URL slug page, which takes the marks off Latin letters.
It does not check that the name is valid in your language
Programming languages have their own rules. Some forbid a name that starts with a digit, some reserve words such as class or return. The page turns text into a name of the right shape, and you still need to make sure the name is legal where you use it. A phrase like 2 for 1 offer becomes 2_for_1_offer, which most languages reject at the start.
The language matters
Scripts written without spaces
Cutting into words needs boundaries. Chinese and Japanese are written without spaces, so a line in those scripts comes back as a single word. The page would rather say so than cut at a place it guessed, since a wrong cut would produce a name that looks plausible and means the wrong thing.
Turkish and the dotted i
Lowercasing follows the rules of the page's language. In Turkish, the small form of I is the dotless ı, and the small form of İ is i. A converter that applies English rules changes the words. This page follows the language it is written in.
German and the sharp s
German ß is already a small letter and is kept, as in straße_17. Capital STRASSE comes back as strasse, because the capital form does not remember whether it came from ß or from two letters.
Right-to-left and Indic scripts
Arabic, Hebrew and the Indian scripts have spaces between words and no case, so the page joins their words with underscores and leaves the letters as they are. Whether a given tool accepts such names is another question.
Where snake_case is the convention
Python and Ruby
The Python style guide recommends snake_case for functions, variables and modules, and Ruby follows the same habit. If you write code in either, your names are almost always in this form.
Databases
Table and column names in SQL are commonly snake_case: customer_id, created_at, order_total. It avoids the need to quote names and is safe across database systems, some of which fold unquoted names to one case and would turn camelCase into an unreadable run of letters.
Data files and APIs
Many web services use snake_case keys in their JSON, and spreadsheets exported for further processing often carry snake_case headers. If your data is on its way through CSV to JSON, the header row becomes the keys, and tidy snake_case headers make the result easy to use.
Constants and environment variables
Constants and environment variables are conventionally written in capitals with underscores: MAX_RETRIES, DATABASE_URL. The way to get them is to convert text to snake_case first and then raise the result with convert text to uppercase.
File names
Lowercase with underscores is a safe file name on every system, and it sorts and searches predictably. Many photographers, researchers and administrators use it for just that reason.
Where it is not the convention
JavaScript and Java
These languages prefer camelCase for variables and functions, and PascalCase for classes. A name from a Python script may need converting before it appears in a JavaScript file. See camelCase for that.
CSS and web addresses
CSS class names and web addresses usually use hyphens, not underscores. The tool for that is kebab-case. Search engines treat a hyphen as a word separator and an underscore as a joiner, a small difference that is behind the habit of hyphenated addresses.
Prose and titles
snake_case is for names, not for reading. A title or a sentence in it is hard on the eye. For human text, keep the words and spaces, and for a heading consider Title Case.
How to convert text to snake_case here
Paste or type your text
Enter the phrase in the first field. The result appears at once in the second, so you can watch it change as you type.
Check the cuts
Look at where the words were divided. A word like iPhone or eBay is cut at the capital, and an acronym such as HTTPServer needs a glance to see that it came out as you intended.
Copy it
Press the copy button and paste the result where you need it. For other forms of the same line, see below.
Using snake_case across a whole project
One convention for the whole stack
A project that mixes naming styles is harder to read than one that is slightly ugly but consistent. If the database uses snake_case, the code that talks to it often does too, and the files that move between them follow. When you convert text to snake_case for a new column or a new field, you are choosing the name that every other layer will have to live with, so choose it once and carry it through.
Moving names between conventions
Sooner or later a name from one convention has to appear in another. A database column customer_first_name becomes customerFirstName in a JavaScript object and customer-first-name in a CSS class or a URL. Rather than retype each by hand, paste the original into the page that produces the form you need: camelCase for code in the C and JavaScript families and kebab-case for styles and addresses. The three forms of the same name are exact translations of one another, and a converter makes them consistently.
Configuration files
Settings files often use snake_case keys, particularly in the YAML used by many tools. When you prepare such a file from data kept as JSON, JSON to YAML keeps the keys as you wrote them, and YAML to JSON does the reverse. Settle on snake_case for keys before you start, and the conversion between formats will not disturb them.
Renaming in bulk
If you inherit a data file whose headers are a mixture of styles, convert each header with this page and replace them in one pass. Test with a small sample first, since a script that reads the file by header will break if a name changes in only some places. Keep a list of old and new names beside the file so that a colleague can see what changed.
Writing names that last
Say what the thing is, not how it is stored
A good name describes the content. order_total says what the number means; col7 does not. When you convert text to snake_case, make sure the phrase you start with is the clearest one you can write, because the converter will preserve its clarity or its muddle faithfully.
Avoid abbreviations that only you understand
A name like cust_fn_dt is a puzzle to anyone else, and to you in six months. Underscores are cheap, and so are extra words. A longer name that reads like a sentence is a better gift to the next person than a short one that needs a legend.
Keep the singular and plural consistent
Decide whether tables are named in the singular, customer, or the plural, customers, and stick to it. The convention matters less than its uniformity. A phrase turned into snake_case keeps whatever number you gave it.
Prefix when it helps
In a large schema, a short prefix groups related names: billing_address, billing_city, billing_country. Typing the phrase with the prefix and converting it gives consistent results, and an alphabetical list then groups itself.
Test the names before you commit to them
Before a name goes into a schema or an API, try it in the places it will appear: a query, a variable, a file listing. If it reads naturally in all three, it will serve. If it feels awkward, shorten or reword the phrase and convert text to snake_case again. A minute of testing at the start spares a rename across hundreds of files later.
The same line in all seven writings
A table of forms
Below the converter, a table shows the example line in all seven forms the site offers: uppercase, lowercase, Title Case, snake_case, kebab-case, camelCase and a URL slug. It is a quick way to see how the same words look in each.
Where these forms come from
Two alphabets
Capital and small letters were once two different alphabets. The capitals are Roman, cut into stone with a chisel; the small letters descend from the Carolingian minuscule, shaped by a pen moving quickly across parchment. Printers kept the two in separate trays, the upper case and the lower case, and the names stuck long after the trays were gone.
Names without spaces
The programming forms are much younger and were invented to solve one problem: a name cannot contain a space. snake_case came out of early C, camelCase out of Smalltalk, kebab-case out of Lisp, and the URL slug out of the need to put a human title into an address where spaces and accents are not allowed. The underscore was a convenient character on the keyboards of the time, and it looks like a space sitting on the line.
Traps when you convert text to snake_case
Starting a name with a digit
Most languages and databases refuse a name that begins with a number. Add a letter or a word in front if the phrase begins with one.
Expecting reserved words to be handled
A phrase like class or order may be a reserved word in your language or in SQL. The page does not know, and you must check.
Acronyms
An acronym inside a camelCase name, such as parseHTMLString, may be cut into parse_h_t_m_l_string or parse_html_string depending on the rule. Check that the result is what you want.
Very long names
Databases and file systems impose length limits. A long phrase turned into a name can run into one. Shorten the wording before you convert.
Questions people ask before converting
What happens to punctuation?
It is treated as a boundary between words and is not carried over.
Are numbers kept?
Yes, as words of their own, separated by underscores.
Does it handle camelCase input?
Yes. A capital inside a word marks a cut, so fooBar becomes foo_bar.
Can I use it for other languages?
Yes, with the rules of the language of the page. Scripts without spaces, such as Chinese and Japanese, come back as a single word.
Is my text uploaded?
No. What you type here is never sent anywhere, so a draft, a password or a client's name is as safe here as in a text editor.
How do I get hyphens instead?
With convert text to kebab-case.
A worked example
Say you are building a small database for a library and the staff have sent you the column titles from their spreadsheet: Book Title, Author's Last Name, Year Published (YYYY), ISBN-13. You convert each in turn and read book_title, author_s_last_name, year_published_yyyy and isbn_13. The apostrophe turned the author column into something untidy, so you shorten the original to Author Last Name and convert again: author_last_name. The year column is clearer without the format note, so you keep year_published. Four tidy column names, written in a minute, and each one a name the database will accept.
A short checklist
Before converting
Write the phrase in plain words, without notes in brackets. Check that the target accepts underscores and accents.
While converting
Paste the phrase, look at the cuts and make sure the name begins with a letter.
After converting
Check the length, check against reserved words and keep a record of the original phrase, so that the name can be traced back to its meaning.
Common mistakes
Using snake_case for text people will read
It is for names, not for prose.
Forgetting what the target allows
Digits at the start, accents and length limits differ between systems.
Converting acronyms without looking
Check the cuts around them.
Your text stays on your device
The conversion happens locally. Your text is handled by your own browser and nothing is sent anywhere. There is nothing to delete afterwards and no account to create. That is the plain way to convert text to snake_case.
Summary
To convert text to snake_case here, paste a line and read it back with the words cut, lowercased and joined by underscores. A line already written in camelCase is cut there too, so fooBar becomes foo_bar. The page does not keep punctuation: commas, dots and dashes are boundaries between words, not characters to carry over, which is what you want for a file name or a database column and not for prose. Cutting into words needs boundaries, so Chinese and Japanese, written without spaces, come back as a single word. Lowercasing follows the language of the page. Nothing is uploaded.