No description
  • Go 88.7%
  • Shell 11.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-21 12:26:52 -05:00
.agents-sync.jsonc chore: sync AI agent instructions 2026-11-21 12:26:52 -05:00
.gitignore initial commit from codex 2026-11-18 06:12:00 -05:00
AGENTS.md chore: sync AI agent instructions 2026-11-21 12:26:52 -05:00
build.sh initial commit from codex 2026-11-18 06:12:00 -05:00
CLAUDE.md chore: sync AI agent instructions 2026-11-21 12:26:52 -05:00
go.mod initial commit from codex 2026-11-18 06:12:00 -05:00
go.sum initial commit from codex 2026-11-18 06:12:00 -05:00
LICENSE initial commit from codex 2026-11-18 06:12:00 -05:00
main.go claude review 2026-11-18 06:12:10 -05:00
main_test.go claude review 2026-11-18 06:12:10 -05:00
README.md claude review 2026-11-18 06:12:10 -05:00
THIRD_PARTY_LICENSES.txt initial commit from codex 2026-11-18 06:12:00 -05:00

jsonc-to-json

Converts JSONC (JSON with // and /* */ comments and trailing commas) to strict JSON, so tools like jq can parse it. Ships as a single static binary with no runtime dependencies.

Usage

jsonc-to-json [-c] [file|-]

Reads from file, or stdin if no file (or -) is given, and writes JSON to stdout.

jsonc-to-json settings.json | jq .
cat settings.json | jsonc-to-json -c | jq 'del(.ssh_connections)'
  • -c compacts the output. Without it, the original layout is kept and comments are replaced with spaces.

  • Output is validated as strict JSON before anything is written. Invalid input writes nothing to stdout, prints an error with the line and column to stderr, and exits nonzero:

    jsonc-to-json: settings.json:3:3: invalid character '"' after object key:value pair
    

Exit codes: 0 success, 1 conversion or I/O error, 2 usage error.

Build

Requires Go 1.20 or newer.

./build.sh            # writes to ./dist
./build.sh ./release  # or a directory of your choice

This builds static (CGO_ENABLED=0) binaries for darwin and linux on amd64 and arm64, named jsonc-to-json-<os>-<arch>.

Run the tests with go test ./....

License

MIT; see LICENSE. JSONC parsing is provided by github.com/tidwall/jsonc, also MIT; see THIRD_PARTY_LICENSES.txt.