Stop squinting at massive JSON logs in your terminal

Text Processing (Grep/Sed/Awk)

Stop squinting at massive JSON logs in your terminal

🧩 The Challenge

Dealing with raw, single-line JSON logs is a special kind of hell when you’re trying to debug an API failure at 2 AM. You end up scrolling horizontally forever trying to find a single field, and honestly, my eyes aren’t what they used to be.

💡 The Fix

Use awk to inject line breaks after every comma or bracket so you can actually read the data structure. It makes a wall of text look like a proper configuration file in seconds.

awk '{gsub(/,/, ",\n"); gsub(/{/, "{\n"); gsub(/}/, "\n}"); print}' logfile.json

⚙️ Why It Works

This command forces the awk interpreter to perform simple string substitutions, inserting a newline character every time it hits a field delimiter. It turns a miserable, unformatted mess into something you can scan with your eyes without getting a headache.

🚀 Pro-Tip: Pipe that into less -S so you can scroll through the now-readable mess without losing your place.

Linux Tips & Tricks | © ngelinux.com | 10/27/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted