Text Minifier
Minimize text by removing unnecessary whitespace and characters
Minimize Options
All text processing is done locally in your browser.
In-depth guide
Text minifier: what Normal and Strict really do
Exactly how the two modes collapse whitespace, why the output is always a single line, why there are no extra option checkboxes, and when minifying text is unsafe.
Key figures at a glance
- Normal mode
- One line, single spaces
- Every run of whitespace, including line breaks, becomes one space; the ends are trimmed.
- Strict mode
- No whitespace at all
- Spaces between words are removed too, so words run together.
- Options
- Normal or Strict only
- The old Remove empty lines, Trim and Normalize spacing checkboxes never changed the result and were removed.
- Statistics
- UTF-16 code units
- Before, after and saved are JavaScript string lengths, so 🙂 counts as 2.
What the two modes do
Press Minimize to run the chosen mode; the result is not live. Empty or whitespace-only input shows an error instead.
| Mode | Operation |
|---|---|
| Normal | Replaces every run of whitespace (spaces, tabs, line breaks, non-breaking spaces and other Unicode spaces) with a single space and removes whitespace at the start and end. Result: one line. |
| Strict | Deletes all whitespace characters. Result: one unbroken string. |
"Whitespace" means JavaScript \s: space, tab, vertical tab, form feed, CR, LF, non-breaking space U+00A0, U+FEFF, U+2028, U+2029 and Unicode space separators such as the ideographic space U+3000. It does not include the zero-width space U+200B, so that invisible character survives both modes.
Worked example
Input (51 characters, with a tab and Windows CRLF line endings):
Hello world
(empty line)
second line
indented
| Mode | Output | After | Saved |
|---|---|---|---|
| Normal | Hello world second line indented |
32 | 19 (37%) |
| Strict | Helloworldsecondlineindented |
28 | 23 (45%) |
Other results from the page's logic: 你好 and 世界 on two lines become 你好 世界 (a space is inserted); a, then lines indented by 2 and 4 spaces, with b and c, becomes a b c.
There are no extra options
The page has only the Normal / Strict choice. Earlier versions also showed Remove empty lines, Trim leading/trailing spaces and Normalize spacing, but they could not change the result: Normal always joins everything into one line and Strict deletes all whitespace. They were removed instead of being left as dead controls.
If you want to keep line structure (for example to remove blank lines but keep line breaks), use Remove line breaks instead; its "Remove blank lines" and "Collapse extra blank lines" modes do exactly that.
Copy and download
Copy puts the output on the clipboard. Download saves it as minimized-text.txt (plain text, created in your browser). Nothing is uploaded.
Counting
Before, After and Saved are JavaScript string lengths, which count UTF-16 code units. The percentage is rounded to the nearest whole number. An emoji such as 🙂 counts as 2, so 🙂 🙂 is 5 before and, in Strict mode, 4 after. For a count that treats an emoji as one character use the word counter.
When not to minify
- Code, JSON-like data, YAML, Markdown, Python. Indentation and line breaks carry meaning. Worse, a line comment swallows what follows:
// noteon one line andx = 1on the next become// note x = 1, which comments out the code. Use a language-aware minifier. - Addresses, poems, tables, lists. The line structure is lost.
- Text where spaces separate words. Strict mode makes it unreadable and cannot be reversed. Keep your original.
- Text with Chinese, Japanese or Thai. These scripts normally do not need spaces; Normal mode keeps single spaces where your text had whitespace, and Strict removes them all.
Tip: The tool saves characters, not file size in bytes. Characters outside ASCII take 2 to 4 bytes in UTF-8.
Common mistakes
- Looking for Remove empty lines, Trim or Normalize spacing checkboxes. They were removed because they had no effect.
- Expecting line breaks to be preserved. Both modes remove them.
- Using Strict mode on text meant for people to read.
- Minifying and then needing the formatting back. There is no undo.
Related tools
Remove line breaks keeps structure while removing blank lines. Hidden character cleaner targets invisible characters. Word counter gives counts that treat emoji as one character. Text diff shows what changed.
Frequently Asked Questions
What is text minification?
Text minification is the process of removing unnecessary whitespace, line breaks, and extra characters to reduce text size while preserving the actual content. It's similar to code minification but for plain text.
When should I use Normal vs Strict mode?
Use Normal mode when you want to reduce text size while keeping it readable (preserves single spaces). Use Strict mode when maximum compression is needed and readability isn't important.
Is my text data sent to any server?
No, all text processing happens entirely in your browser. Your data never leaves your device, making this tool completely safe for sensitive documents and content.
How much can I reduce text size?
The reduction depends on the original text. Text with lots of extra spaces, line breaks, or formatting can see 20-50% size reduction. The tool shows exact before/after character counts.
Can I undo minimization?
No, minification is one-way and removes whitespace permanently. Always keep a copy of your original text before minimizing if you might need the original formatting.
What's the difference between text minifier and compressor?
Text minification removes unnecessary characters but keeps the text readable. Compression (like ZIP) uses algorithms to encode data, which requires decompression to read.
Can I use this for code?
While you can use this for code, dedicated code minifiers are better as they understand syntax. This tool is best for plain text, content, and documentation.
Sources
- MDN — Regular expression character class escape (\s) — Defines which characters count as whitespace.
- MDN — String length
This guide explains published rules in plain language. It is not financial, legal or official advice — rules change, so confirm with the agency linked above before you commit.
Embed this tool on your website
Free to use. Paste this code into your page and keep the link back to ToolSG.