Text cleaner and editor
- Lines before
- Lines after
- Characters before
- Characters after
- Replacements
Everything runs in your browser; nothing is sent or stored.
- Paste the text in the "Text" field, and the result updates as you type and whenever you change the operations.
- In the "Cleaning" section, select the operations you need, for example, removing duplicate lines or removing empty lines.
- Removing hidden characters removes direction marks (such as RLM), zero-width characters, soft hyphens, control characters, and tag characters, and replaces special spaces with a normal space, as the Invisible character detector tool does by default.
- In the "Sort and order" section, choose to sort A-Z or Z-A, reverse the line order, or shuffle the lines in random order.
- In the "Find and replace" section, enter text or a regular expression in the "Find" field, and every occurrence is replaced with the text in the "Replace with" field.
- In the "Add to each line" section, add text at the start or end of each line, number the lines, or join them into one line.
- The chosen operations always run in this order: remove hidden characters, find and replace, remove spaces at line ends, collapse spaces, remove empty lines, remove duplicate lines, sort, reverse, shuffle, add text to lines, number, and join into one line.
- Above the "Edited text" field, the tool shows the number of lines and characters before and after editing and the number of replacements. To copy the text, click "Copy".
Operations run in a fixed order
The selected operations always run in the same order, regardless of the order in which you selected them. Removing hidden characters runs first, followed by find and replace, and only then line cleaning, sorting, the text added to each line, and finally joining into one line. As a result, two lines that become identical after the replacement are detected as duplicates, and the numbering follows the order after sorting.
Hidden characters in copied text
Text copied from documents, PDF files, or websites sometimes contains characters that are not visible on the screen, such as direction marks (RLM), zero-width characters, and a non-breaking space instead of a normal space. Hidden characters can disrupt find and replace and sorting, so we recommend removing them before editing. Removing hidden characters deletes these characters and replaces special spaces, such as a non-breaking space, with a normal space. To find the hidden characters in a text and identify the type of each character, use the "Invisible character detector" tool.
How lines are sorted
Lines that start with digits come first, followed by lines that start with letters. When two lines differ only in letter case, the lowercase line comes before the uppercase one. Without sorting numbers by value, numbers are compared as text, character by character, so 10 comes before 2. The "Sort numbers by value (2 before 10)" option compares numbers by their size and suits lists of order numbers, ports, or IP addresses.
Find and replace with a regular expression
In a plain search, the text in the "Find" field is replaced exactly as written, including periods and special characters, and the $ sign in the "Replace with" field is also inserted as written. When the "Regular expression (Regex)" option is selected, you can search for patterns, such as numbers or addresses, and use captured groups in the replacement, for example, $1. The ^ and $ signs match the start and end of each line, so you can edit each line separately. To build an expression and test its matches, use the "Regex tester" tool.
Common regular expressions for find and replace
(\d{4})-(\d{2})-(\d{2})a date in the format2024-01-15. With the replacement$3/$2/$1, the date becomes15/01/2024.^\d+[.)]\s*numbering at the start of a line, such as "1." or "2)". When the "Replace with" field is empty, the numbering is removed.https?://\S+an address that starts withhttp://orhttps://, up to the next space.\na line break. With the replacement", "(a comma and a space), the lines become a list on one line.\p{L}+a run of letters in any language, for example, a word.
Text cleaner and editor FAQ
Why are two lines that look identical not removed as duplicates?
Usually, one of the lines has a hidden character, a space at the end of the line, or a difference in upper and lower case. Select the "Remove hidden and direction characters" and "Remove spaces at the start and end of each line" options, and for text with upper and lower case letters, also the "Ignore upper and lower case when comparing duplicate lines" option.
Is the search case-sensitive?
Yes. The search is case-sensitive unless the "Ignore upper and lower case" option in the "Find and replace" section is selected. The option applies to both a plain search and a regular expression, and it does not affect the comparison of duplicate lines, which has a separate option in the "Cleaning" section.
Is the line shuffle truly random?
Yes. The shuffle is based on a cryptographic random number generator, and every possible order of the lines is equally likely. Every change to the text or the operations creates a new shuffle.
How do numbering and the text added to each line work?
The number is written at the start of the line, before the text in the "Text at the start of each line" field. Empty lines get no number and no added text, and the numbering continues in sequence on the next line that is not empty.
What happens when the regular expression is invalid or slow?
When the expression is not valid, an error message describing the problem appears instead of the result. A regular expression search that takes more than one second is stopped, because some expressions retry the same part of the text over and over (backtracking) and can take a very long time.
What is the maximum size of text to clean and edit?
The text can be up to 1 MB, and the result can be up to 2 MB. A regular expression search runs on text of up to 1,000,000 characters, and the "Find", "Replace with", "Text at the start of each line", and "Text at the end of each line" fields accept up to 1,000 characters each.