DevTools Pro · All tools · About

Text Formatter

About the Text Formatter

This text formatter cleans up messy text in one pass: collapse extra spaces, trim lines, remove empty or duplicate lines, sort or reverse lines, and change case. Pick the cleanup rules you need, apply them together, and copy the tidy result.

What each formatting option does

Extra Spaces turns any run of spaces or tabs into a single space but leaves line breaks alone. Trim Lines strips leading and trailing whitespace from every line, while Trim Text only trims the very start and end of the whole text.

Line Breaks converts Windows (\r\n) and classic Mac (\r) line endings to Unix \n. Empty Lines deletes blank lines, including lines that contain only spaces, and Duplicates keeps the first occurrence of each line and drops later repeats.

Sort Lines orders lines A to Z using natural sorting, and Reverse Lines flips the order of lines. The four case options (UPPERCASE, lowercase, Title Case, Sentence) are mutually exclusive, so selecting one deselects the others.

In what order are the rules applied?

No matter which order you click them, options always run in this sequence: line breaks, trim lines, extra spaces, empty lines, duplicates, sort, reverse, trim text, then case. A fixed order gives the same output every time.

This matters when you combine rules. Turning on Sort Lines and Reverse Lines together gives a Z to A list. Turning on Trim Lines with Duplicates catches lines that only differed by trailing spaces, because trimming happens first.

Natural sort vs alphabetical sort

A plain alphabetical sort puts item10 before item2, because it compares characters one by one. Natural sorting reads the numbers as numbers, so the list comes out as item1, item2, item10.

Sorting is also case-insensitive and ignores accents when comparing, so apple, Banana and cherry stay in the expected order instead of grouping all capitalized words first.

Gotchas worth knowing

Duplicate removal is exact and case-sensitive: Apple and apple are kept as two lines. Apply lowercase first in a separate pass if you want them merged.

Removing empty lines also removes the blank lines that separate paragraphs, which joins them into one block. Title Case capitalizes every word, including short words like "of" and "the".

How to Use the Text Formatter

  1. Paste your text into the Raw Content box.
  2. Under Formatting Options, click each rule you want, for example Extra Spaces, Empty Lines and Duplicates. Active options turn teal.
  3. Optionally choose one case style: UPPERCASE, lowercase, Title Case or Sentence.
  4. Click Apply Formatting to see the cleaned text in the Result panel.
  5. Press Copy to grab the result, or Clear to reset the input and all options.

Frequently Asked Questions

Why is the Apply Formatting button disabled?
It needs both some input text and at least one selected option. Paste your text and click an option to enable it.
Can I use more than one case option?
No. Only one case style can be active at a time; choosing another one replaces the previous choice.
Does removing duplicates keep the first or last copy?
The first occurrence of each line is kept in its original position and later duplicates are removed.
Why did my paragraphs merge into one block?
Empty Lines removes the blank lines between paragraphs. Leave it off and use Extra Spaces or Trim Lines if you want to keep paragraph breaks.
Does sorting treat uppercase and lowercase differently?
No. Sorting ignores case and accents and compares numbers by value, so the order reads naturally.
Is my text uploaded?
No. Formatting runs in your browser with JavaScript and your text never leaves the page.

Related tools