Remove Control Characters from JSON Instantly (Free Tool)
Instantly fix “SyntaxError: Bad control character” by stripping invisible ASCII characters. A rescue tool for corrupted JSON files.
How to Fix “Bad Control Character” Errors
If you have ever pasted JSON and received a parsing error despite the code looking perfect, you likely have hidden control characters. Here is how to clean them:
- Step 1: Paste your raw, broken JSON string into the editor above.
- Step 2: Click “Clean & Format”. Our engine scans for invisible bytes (0x00-0x1F).
- Step 3: The tool strips the illegal characters while preserving valid formatting like tabs and newlines.
- Step 4: Copy the sanitized, valid JSON back to your application.
Technical Deep Dive: What are Control Characters?
The JSON Specification (RFC 8259) is strict. Strings must not contain “control characters” unless they are escaped (e.g., `\n` or `\t`).
The “Gremlins” We Remove:
- Null Byte (\u0000): Often causes string truncation issues in databases.
- Vertical Tab (\u000B) & Form Feed (\u000C): Common in old printer logic but illegal in JSON strings.
- Backspace (\u0008): An archaic character that moves the cursor back.
- Unescaped Line Breaks: A literal newline inside a string (not `\n`) breaks the parser.
Our tool uses a precise Regular Expression to target the ASCII range 0x00-0x1F (excluding valid whitespace) to sanitize your data without deleting your actual content.
Why Use Our Cleaning Tool?
1. Privacy-First & Secure
Corrupted JSON often comes from production logs or database dumps containing PII. Unlike server-side API tools, this cleaner runs 100% in your browser. Your sensitive logs never leave your device.
2. Smart Sanitization
We don’t just delete everything. We preserve:
- \t (Tab): Essential for code indentation.
- \n (Newline): Essential for multi-line text (when properly escaped).
We surgically remove only the characters that are strictly forbidden in JSON syntax.
Explore More JSON Tools
Fix, format, and convert your data with our suite of free utilities.
Frequently Asked Questions
What exact characters are removed?
We remove ASCII characters 0 through 31 (0x00-0x1F), with the exception of Tab (0x09), Line Feed (0x0A), and Carriage Return (0x0D).
Does this fix “Unexpected token” errors?
It fixes errors caused by invisible characters. If you have a missing comma or quote, use our JSON Validator instead.
Can I use this for large log files?
Yes. Since it runs locally in your browser memory, it can process large text dumps efficiently without uploading them to a server.
