Key takeaways
- Replacement runs first; spaces, trim, blank removal and duplicates follow.
- Natural sort compares embedded numbers, placing item2 before item10.
- Regex replacement uses the regex tester's disposable worker and 500 ms timeout.
The text cleaner tidies pasted text with explicit line, spacing, sorting and replacement controls. Use it for repeated list entries, copied notes or text with inconsistent whitespace. It shows before/after character and line counts, counts removed duplicates and blanks, and offers a plain-text download as well as copying.
The cleaner works on the text you enter in the browser. It does not interpret a list as a spreadsheet or understand the meaning of a sentence. Each option has a mechanical effect, so choose only the transformations that suit the content. Keep a source copy when line breaks, indentation or repeated entries may be meaningful.
Before you start
Decide whether you are cleaning a list or prose. In a list, duplicate removal and sorting can be useful. In prose, repeated lines and paragraph breaks may be intentional. In code, spaces and indentation can affect meaning. Read the selected checkboxes before pressing Clean text rather than assuming the default cleanup fits every input.
The starting options enable trimming, extra-space collapsing, blank-line removal and duplicate-line removal. Sorting starts at Keep order, and joining line breaks starts disabled. Plain replacement is the default. The initial example lets you see those choices on a small list before pasting your own material.
Consider whether replacement should be literal or pattern-based. Plain mode finds exact, case-sensitive substrings and inserts replacement text literally. Regex mode uses JavaScript regular expressions and replacement tokens. Start with Regex Tester if you need to inspect captures before applying a pattern to a useful list.
Step by step with CrizaTools
- Paste content into Input text. Keep the original somewhere if you may want to compare it later.
- Optionally enter Find and Replace with. Empty Find skips replacement; an empty replacement deletes matches.
- Enable Use regular expression only when needed and set Regex flags. The
gflag replaces all matches rather than only the first. - Choose Trim each line, Collapse extra spaces and tabs within lines, Remove blank lines and Remove duplicate lines as appropriate.
- Choose Sort lines: Keep order, A–Z, Z–A or Natural.
- Enable Remove line breaks only if the final output should be one space-joined line.
- Press Clean text, review the counts and cleaned text, then use Copy cleaned text or Download text.
Changing any input or setting immediately clears the old result and download. Press Clean text again to generate a matching output. Clear text empties the input and cancels a pending worker job; it does not delete any text files already saved to your device.
Two worked examples
Example 1: clean and naturally sort a small list. Paste apple , apple, a blank line, item10 and item2 as five lines. Keep trim, space collapsing, blank removal and duplicate removal enabled. Select Natural sort and leave line-break removal disabled.
Spaces are collapsed, each line is trimmed, the blank is removed and the two resulting apple lines are recognised as identical. Natural sorting places the final three lines in the order apple, item2, item10. Counts report one blank line removed and one duplicate removed. Ordinary A–Z instead compares the text without numeric sorting, so it can place item10 before item2.
Example 2: transform a captured identifier. Paste ID: 12 and ID: 3 on two lines. Set Find to ID: (\d+), Replace with to item$1, enable regular expressions and use flags g. Choose Natural sort and leave line joining off.
The regex captures each numeric part and produces item12 and item3. Natural sort then gives item3 followed by item12, with two replacements reported. Plain mode would not interpret the parentheses or digit pattern as regex syntax, and its replacement would treat $1 literally. The example therefore depends on both the regex checkbox and the chosen flags.
Operation order and counts
The pipeline is fixed: replacement, line-ending normalisation, extra spaces, trim, blank-line removal, duplicate-line removal, sorting, then optional joining. Windows CRLF and standalone CR become LF. Duplicate detection sees the text after replacement and whitespace choices, so enabling trim can make two previously different lines identical.
Duplicates are case sensitive. Apple and apple remain distinct. Blank removal recognises whitespace-only lines even when trim is off. If blank removal is off but duplicate removal is on, repeated identical empty lines can count as duplicates instead. The two removal counts describe what each stage actually removed rather than an abstract count from the untouched input.
Character counts use Unicode code points and include line breaks. They are not byte counts or a guarantee of visible glyph count: some displayed symbols use multiple code points. Line counts include a trailing empty line where present. Net characters removed can be negative when replacement expands the text; that simply means the final text is longer.
Limits and regex behaviour
Plain-mode fields allow up to 10 MB each, and replacement expansion is bounded. Use smaller sections for very large lists, particularly on phones. Sorting and whole-text transformations need working memory in addition to the original pasted text.
Regex uses the existing disposable worker with a 500 ms timeout. Its limits are 20,000 input characters, 1000 pattern characters, 2000 replacement characters, 1000 matches and 1,000,000 output characters. A difficult pattern can time out even within these size limits. Shorten the input or simplify the expression when the tool reports a timeout.
Regex replacement follows JavaScript substitution rules, including captured-group tokens such as $1. The ECMAScript replacement specification, checked 16 November 2026, defines those substitutions. Plain mode deliberately inserts the replacement literally instead. No regular expression runs on the main interface thread.
Common mistakes
- Sorting prose or code whose original order matters.
- Enabling duplicate removal when repeated entries represent separate events.
- Expecting duplicate detection to ignore letter case.
- Forgetting
gwhen a regex should replace every occurrence. - Using capture tokens in plain mode and expecting interpolation.
- Joining line breaks before checking whether separate list items remain readable.
Questions and answers
Does trim remove spaces inside a sentence?
Trim removes leading and trailing whitespace on each line. The separate extra-space option collapses internal runs of spaces or tabs. Disable that option when internal spacing has meaning.
Is natural sort a numerical calculation?
No. It uses English text collation with numeric comparison for embedded digit sequences. It is useful for identifiers such as item2 and item10, rather than interpreting every line as a mathematical value.
Why does regex replacement stop?
The worker is terminated after 500 ms, or an explicit size, match or output limit can reject the job. The error explains the condition. Simplify the expression or use a smaller input before retrying.
Can the output be empty?
Yes. Replacement and cleanup can remove everything. The result and counts still appear, and a text download is available. The copy button is disabled when there is no text to copy.
Are inputs shared in links or analytics?
No. Text stays in browser state and the regex worker on your device. The tool does not write input text into page URLs or analytics. Downloaded text is a local output file you choose to save.
Free tools for this
PDF & image
Text Cleaner
Clean text by trimming spaces, removing duplicate or blank lines, sorting naturally and replacing plain text or regex matches.
PDF & image
Regex Tester
Test JavaScript regular expressions with flags, live match highlighting, capture groups and replacement preview.
PDF & image
Word Counter
Count words, characters with and without spaces, sentences and paragraphs as you type, with reading and speaking time.