@kszongic/jsonc-strip-cli
v1.0.0
Published
Strip comments from JSONC files to produce valid JSON
Maintainers
Readme
@kszongic/jsonc-strip-cli
Strip comments and trailing commas from JSONC files to produce valid JSON. Zero dependencies.
Handles // single-line comments, /* */ multi-line comments, and trailing commas — the three things that make JSONC files invalid JSON.
Install
npm install -g @kszongic/jsonc-strip-cliUsage
# Strip comments from a file
jsonc-strip tsconfig.json
# Pipe from stdin
cat config.jsonc | jsonc-strip
# Edit in-place
jsonc-strip -i tsconfig.json
# Minified output
jsonc-strip -m config.jsonc
# Custom indentation
jsonc-strip -s 4 config.jsoncOptions
| Flag | Description |
|------|-------------|
| -i, --in-place | Overwrite the file with stripped output |
| -m, --minify | Output minified JSON |
| -s, --spaces N | Indentation spaces (default: 2) |
| -h, --help | Show help |
| -v, --version | Show version |
Example
Input (tsconfig.json):
{
// TypeScript compiler options
"compilerOptions": {
"target": "ES2020", /* output target */
"strict": true,
}
}Output:
{
"compilerOptions": {
"target": "ES2020",
"strict": true
}
}License
MIT © kszongic
