How to clean JSONL files with JSONL Cleaner
Paste JSON Lines into JSON Lines input, or load a JSONL, NDJSON, or TXT file. JSONL Cleaner reads one record per line, removes blank and invalid lines, trims string values, and can deduplicate by cleaned line or a selected key. A parse error is recorded while later lines continue processing.
- Paste content into JSON Lines input, or use Drop a JSONL or NDJSON file here and browse files.
- Leave Trim string values selected to remove leading and trailing whitespace inside strings.
- Under Deduplicate, choose Do not deduplicate, By full cleaned line, or By a selected key.
- For By a selected key, enter the field name in Key name to dedupe by.
- Review Changes made, then use Copy Cleaned JSONL, Export JSONL, or Export Discard Report (CSV).
Remove invalid JSONL lines
Each non-empty line is parsed on its own. Blank or whitespace-only lines are discarded, and a line that fails JSON parsing is added to the discard report with its line number and parser message. Later lines still run through the cleaner.
With Trim string values selected and Do not deduplicate chosen, this input:
{"id":1,"name":" Alice "}
bad line
{"id":1,"name":"Alice"}
produces this output:
{"id":1,"name":"Alice"}
{"id":1,"name":"Alice"}
The empty split item created by a final newline is ignored as a record.
Trim string values in JSONL records
Trim string values walks through objects and arrays and removes leading and trailing whitespace from every string it reaches. Numbers, booleans, nulls, arrays, and object fields stay in the parsed record. JSON.stringify writes the output compactly, so original indentation is replaced.
Input: {"id":1,"name":" Alice "}
Output: {"id":1,"name":"Alice"}
Deduplicate JSONL by line or key
By full cleaned line compares the complete cleaned JSON serialization and keeps the first copy. Trimming happens first, so two records that become identical after trimming count as duplicates.
By a selected key compares the named field and keeps the first object for each value. Arrays, primitive values, and objects without that field stay in the output. An empty Key name to dedupe by field shows an error and stops processing.
Review and export cleaned JSONL
Processing starts after usable input arrives and runs again when a setting changes. Changes made reports lines read, records kept, blank lines removed, invalid JSON lines removed, duplicates removed, and strings trimmed.
Before and After show the input and cleaned output. The discard report records discarded lines and modified records with line number, action, details, original content, and cleaned content when available. The table shows the first 500 entries. Original and cleaned content fields are truncated to 200 characters in the table and CSV. Export Discard Report (CSV) saves the report rows.
Where JSONL cleaning comes up
When some records are malformed, the cleaned output leaves out lines that fail JSON parsing while the discard report keeps their line numbers and parser messages.
When repeated records share an id field, select By a selected key and enter id to keep the first object for each value. Records without that field remain available in the output.
JSONL Cleaner or JSON Cleaner?
Use JSON Clean Tools when each line is an independent JSON record and you need line-level removal, deduplication, or reporting. Use JSON Cleaner for one JSON document when you need to remove selected null or empty values, sort object keys, deduplicate array items, or strip JSONC comments.
Processing and file errors
The cleaner reads pasted text and files in the browser, then creates copied text and local downloads. The page does not send the input to a server. Empty input waits for usable JSONL, and an unreadable file displays an inline error.
Frequently asked questions
How do I clean a JSONL file?
Paste JSONL into JSON Lines input or load a JSONL, NDJSON, or TXT file, then review the result. Set trimming and deduplication before copying or exporting the cleaned output.
Can JSONL Cleaner remove invalid JSON lines?
Yes. Lines that fail JSON parsing are removed from the cleaned output and added to the discard report with their original line number and parser message. Later lines continue processing.
How do I deduplicate JSONL by id?
Choose By a selected key in Deduplicate, enter id in Key name to dedupe by, and the cleaner keeps the first object for each id value. Records without that field remain.
What does the JSONL discard report contain?
The report contains discarded lines and modified records, including line number, action, details, original content, and cleaned content when available. The table shows up to 500 entries. Original and cleaned content are truncated to 200 characters in exported rows.