How to fix malformed json lines in log files
- Step 1Extract the problematic log lines — Identify the lines causing parse failures in your log processing pipeline. Copy a batch of the failing lines to inspect and repair.
- Step 2Run the format fixer on the log lines — Paste the log lines. For NDJSON (newline-delimited JSON), each line is fixed independently. Common issues detected: unescaped newlines in exception stack traces, truncated JSON at line end, extra text before the JSON object.
- Step 3Review fixable vs unfixable lines — The fixer reports which lines were fixed and which are too corrupted to repair. Download the fixed lines for reprocessing and note the unfixable lines for manual investigation.
- Step 4Add resilience to the log parser — Update the log processing pipeline to use a lenient JSON parser or wrap JSON.parse in try/catch with a fallback to raw string logging. Log the unparseable lines to a separate error log for manual review.
Frequently asked questions
How do I handle multi-line exception stack traces in JSON log lines?+
Exception stack traces contain newlines that break JSON line parsing. The correct fix is at the logger: escape newlines in string values before logging (\n →’ \\n). If you cannot change the logger, pre-process log lines with a regex that joins lines belonging to the same JSON object before parsing.
What is NDJSON and why is it used for logs?+
NDJSON (Newline-Delimited JSON) is a format where each line is a complete JSON object. It is ideal for logs because each event is self-contained and parseable independently — you can process logs line-by-line without loading the entire file. Popular logging libraries (Pino, Bunyan, Winston JSON format) output NDJSON.
Is the log data transmitted to JAD Apps?+
No. Format fixing runs entirely in your browser. Log data with request details and user actions is never transmitted to JAD Apps servers.
Privacy first
Conversion runs locally in your browser. No file is uploaded — only metadata counters are saved for signed-in dashboard stats.