Crates.io | jcfmt |
lib.rs | jcfmt |
version | 0.1.1 |
created_at | 2025-08-16 05:50:02.412094+00 |
updated_at | 2025-08-17 10:42:24.133302+00 |
description | A command-line tool to format JSONC (JSON with Comments) text |
homepage | https://github.com/sile/jcfmt |
repository | https://github.com/sile/jcfmt |
max_upload_size | |
id | 1798033 |
size | 26,603 |
jcfmt
is a command-line tool to format JSONC (JSON with Comments) text.
Before:
{"name":"example", // App name
// config and features
"config": {"debug":true, "port":8080/* TODO: fix later */},
"features": ["auth","logging"] ,}
After:
{
"name": "example", // App name
// config and features
"config": {
"debug": true,
"port": 8080 /* TODO: fix later */
},
"features": ["auth", "logging"],
}
//
) and block comments (/* */
)$ cargo install jcfmt
$ jcfmt -h
A command-line tool to format JSONC (JSON with Comments) text
Usage: jcfmt [OPTIONS]
Options:
--version Print version
-h, --help Print help ('--help' for full help, '-h' for summary)
-s, --strip Remove all comments and trailing commas from the JSON output
// Simple example
$ echo '{/*foo*/"bar":"baz"}' | jcfmt
{ /*foo*/
"bar": "baz"
}
// Complex example
$ cat example.jsonc
{"name":"example", // App name
/* config and
features */
"config": {"debug": true, "port": 8080 /* TODO: fix later */},
"features": ["auth", "logging", ],
}
$ cat example.jsonc | jcfmt
{
"name": "example", // App name
/* config and
features */
"config": {
"debug": true,
"port": 8080 /* TODO: fix later */
},
"features": ["auth", "logging",],
}
// The `--strip` flag produces plain JSON output
$ cat example.jsonc | jcfmt --strip
{
"name": "example",
"config": {"debug": true, "port": 8080},
"features": ["auth", "logging"]
}