Skip to content

kg1990/json_viewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Viewer

A native macOS JSON tool built with SwiftUI on top of the JSONCore library.

What it does

A two-pane window: edit JSON on the left, see formatted output on the right.

  • Beautify — pretty-print the input using the selected indent style.
  • Minify — collapse the input to a single compact line.
  • Validate — check the input and show a clear inline status: green "Valid JSON", or red line L, column C: message on a parse error.
  • Compare — open a JSON Compare window with two editors (A original / B compare), a summary of added/removed/changed counts, and a recursive tree diff that highlights additions (green), removals (red), and changes (orange, shown as old → new).
  • Clear — empty both panes.
  • Indent picker — 2 Spaces / 4 Spaces / Tab, applied to Beautify and to extraction results.
  • Beautify/Minify on invalid input shows the parse error instead of garbage output.

Transform tools

A row of one-click text transforms (above the panes). Each applies to the input and shows its result in the Output pane with a left line-number gutter (monospaced, read-only, selectable). On error the message is shown in red. The output reverts to the JSON Text/Tree view as soon as you edit the input or click Beautify / Minify / Validate / Clear.

  • JSON Escape / JSON Unescape — escape/unescape JSON string contents.
  • BASE64 Encode / BASE64 Decode — Base64 of UTF-8 bytes.
  • URL Escape / URL Unescape — percent-encoding.
  • Gzip&BASE64Encode / BASE64Decode&Ungzipreal gzip (via zlib), interoperable with the system gunzip / gzip tools.
  • String UnEscape — decode escape sequences without stripping outer quotes.

Extraction

Enter a path in the Path field and press Extract (or Cmd+Return). Results open in a separate window showing the pretty-printed matches and a count of extracted items. The result window has:

  • Copy — copies the result text to the clipboard.
  • Download — saves the result to a .json (or .txt) file.

Bad paths or invalid JSON show the error in the result window instead of crashing.

Path syntax

A JSONPath subset over the ordered JSON model:

  • optional leading $
  • .key — object member access
  • ['key'] / ["key"] — quoted object member access
  • [<integer>] — array index access (negative indices count from the end)
  • [*] — wildcard over array elements

chained arbitrarily. Missing keys, out-of-range indices, and type mismatches are skipped (never crash).

Examples:

$[*].id
.data.items[0]
['key']
$.users[*].name
$.items[-1]

Build

This project targets a Command Line Tools-only environment. SwiftPM (swift build / swift test) and xcodebuild are not used — everything is compiled with swiftc directly.

./build_lib.sh    # compile JSONCore into build/libJSONCore.dylib
./run_tests.sh    # run the JSONCore test suite
./build_app.sh    # compile + bundle build/JSONViewer.app

build_app.sh compiles JSONCore + the SwiftUI app with swiftc -parse-as-library, writes the Info.plist, lints it with plutil -lint, and prints the .app path. It exits non-zero on compile failure.

Run

open build/JSONViewer.app

The app is unsigned, so on first launch macOS Gatekeeper will block it. Right-click the app → Open, then confirm in the dialog. Subsequent launches work normally.

Constraint

Built and verified on macOS 14.4 (arm64) with Swift 5.9 Command Line Tools only. No Xcode, no SwiftPM build/test — swiftc direct compilation only.

About

Free, native macOS JSON viewer & formatter — beautify, minify, validate, tree view, JSONPath extraction, and base64/url/gzip transforms. Offline & private.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors