Tools Hub

Clean messy text in the right order: spaces, duplicates, accents

Sequence five text cleaners so each one sees the problem the previous step removed, without creating new damage.

Cleaning text is not one action but a short sequence, and order changes the result. Collapsing spaces before removing duplicates merges lines that were distinct, while stripping accents first can hide the duplicates you meant to find. Here is an order that stays predictable.

Start with line-level noise: whitespace and blank lines

The whitespace cleaner trims each line, collapses runs of spaces and drops empty lines. Do this first so duplicates are compared on content rather than on invisible padding, and so later tools do not treat a blank line as a row.

Remove duplicates before changing characters

Duplicate removal keeps the first occurrence in order. Run it while lines still differ only by padding, not after accent stripping or case changes that could merge genuinely different entries into one.

Normalise characters last and deliberately

Accent removal, smart-quote conversion and character stripping change content, not layout. Apply only the transformation the destination needs: an English slug may want accents removed, while a names list usually should keep them.

Tools covered in this guide

Frequently asked questions about text cleanup order

Should I remove duplicates before or after trimming spaces?

After trimming. Otherwise two identical lines with different padding are treated as different and both survive the deduplication step.

Will removing accents change the words?

It changes letters such as é to e, which is fine for slugs and search keys but wrong for names, citations or anything a human will read as written.

Does converting smart quotes affect code?

Yes. Straight quotes are syntactically meaningful in code and JSON, while curly quotes look similar but break parsing, so convert before pasting into a code editor.

More guides