Skip to content
Allin

Trim each line

Remove leading and trailing whitespace from every line.

Trim each line is free to use as often as you like, directly from this page. You will find it under Transform & clean, with Duplicate each line and Quote each line for the neighbouring cases.

How to use it

  1. Open the tool — no signup or install needed.
  2. Enter your input or adjust the available options.
  3. Get your result instantly, then copy or download it.

Frequently asked questions

What is Trim each line?

Remove leading and trailing whitespace from every line.

When would I actually use this?

Cleaning up a paste before it goes anywhere: stripping duplicates from a list, normalising case, removing accents for a filename, or sorting lines.

What is the most common mistake?

Sorting text as if it were ASCII. Accented letters land after Z in a byte sort, which puts "Zurich" before "Émile" and produces a list no reader will accept.

How is Trim each line different from Duplicate each line?

They sit next to each other but answer different questions: Duplicate each line is the one to open when you need it to repeat every line a chosen number of times. Pick whichever matches what you're starting from — both are free.

Is there a tool for the next step?

Quote each line is the closest one after this: Wrap every line in quotes, with an optional trailing comma — handy for code arrays.

What else is worth having open alongside it?

Reverse each word and Add line numbers — they come up in the same task often enough to be worth a second tab.

Where do the figures come from?

Transformations use the browser's Unicode-aware string handling, so case changes and sorting respect the locale rather than byte order. Nothing is truncated: what comes out is the whole of what went in.

Further reading

All guides
ExplainerFinding Duplicates in a List Without a SpreadsheetTwo lines that look identical are often not identical. Case, a trailing space, a no-break space and two different encodings of the same accented letter were each run through the duplicate finder, and it reported no duplicates for three of the four.GuideCleaning Up a List Pasted from a Spreadsheet or a PDFA paste carries characters you cannot see: no-break spaces, soft hyphens, zero-width spaces, tabs and CRLF. Four cleanup tools were run against each of them, and they use three different definitions of whitespace.How-toNumbering the Lines of a Text for a Review with Several PeopleNumbering starts at 1 and cannot be set to 0, the alignment is spaces rather than zeros, and the remover undoes eight of the eleven separators without touching the indentation. What it still cannot do is tell your numbers from its own.How-toCleaning Messy Text: The Order of Operations That Actually MattersStrip tags before decoding entities, trim before deduplicating, collapse whitespace last. Three orderings run in Node, a nine-step pipeline in the right sequence, and the invisible characters — U+00A0, U+200B, U+FEFF — that survive every naive cleanup.GuideStripping Markdown: What Plain Text Loses, and What a Regex Gets WrongA link becomes text with its destination deleted, a nested list loses its hierarchy, a table becomes a row of words. Then the technical half: markdown has no single spec, and a regex stripper mangles a filename, a multiplication sign and the inside of a code block — all shown against a real parser.ExplainerSorting Text Is Not One Operation: Four Orderings That All Call Themselves AlphabeticalCode-unit order, natural order and locale collation run on the same list in Node, with the outputs printed. Why Zebra beats apple, why item10 beats item9, and why ä sits next to a in German but after z in Swedish.