Add coloured JSON output with --pretty and Ctrl+T - #171
Open
WietseWind wants to merge 1 commit into
Open
Conversation
WietseWind
force-pushed
the
feature/json-pretty-print
branch
from
September 9, 2026 11:24
88b6484 to
fd1b4af
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Large JSON replies are hard to read on one line. Add optional indentation and colours.
Changes
--prettyto start with indented, coloured JSON output. Without thisflag, formatting starts off.
state. Keep the draft and cursor intact.
--no-colorfor indentation only. Do not write colour reset codes whencolours are disabled.
binary messages, and piped output unchanged.
Demo
Full demo: 13 seconds, 1 MB GIF.
Security overview
commander,ws,https-proxy-agent, andreadremain in use.readline,tty, and event handling. Add the built-instreammodule for Ctrl+T input handling. Tests also use built-in
util.These modules ship with Node.js; no extra package downloads or install scripts.
JSON.parseto validate messages, then format the original tokens withstring operations and ANSI colours. Do not execute message text.
Keep large numbers, duplicate keys, and string escapes intact.
Formatting adds no file writes or network requests.
Validation
Ctrl+T, exact numbers, cursor position, and ordinary arrow recall.