Skip to content

fracjson CLI

j-brooke edited this page Feb 1, 2026 · 3 revisions

fracjson is a command line tool for formatting JSON data so that it's fairly compact but highly readable. It uses the FracturedJson .NET library. It's available as a dotnet global tool for people who use the .NET ecosystem, and as a standalone executable for major platforms for people who don't want to install .NET.

Several of the implementations in other languages also provide CLI tools. See Available Versions and Ports to find one that suits your needs.

Installing

To install as a .NET tool, type this:

dotnet tool install --global fracjson

You'll need a .NET runtime installed on your machine to use it, of course.

If you're rather not use .NET, you can download one of the self-contained executables from the FracturedJson Releases page. You'll have to decide where to put the file on your own and make sure it's set as an executable with chmod or similar. You might also want to put it in your $PATH.

Usage

Use a file or stdin to specify the input file. The output will be sent to your terminal, unless you pipe it somewhere. Alternately, you can use the --output-file switch (or -o) to write it directly to a file.

fracjson rawFile.json -o formattedFile.json
echo '{"a":3,"b":false}' | fracjson > out.json

Settings

All of FracturedJson's settings are available the command line. See the Options wiki page for examples of how they work. You can use an exact property name from FracturedJsonOptions with a double-dash - for instance, --MaxTotalLineLength, or shorter kabob-case versions such as --length or, in some cases, single letter versions like -l.

Use --help to list the settings.

Description:
  Reformats a JSON document to make it highly human-readable.

Usage:
  fracjson [<inputFile>] [options]

Arguments:
  <inputFile>  Input JSON file (reads from stdin if omitted)

Options:
  --config <config>                                           File containing FracturedJsonOptions
  --no-config                                                 Ignore any config file; use only CLI / defaults
  -o, --output-file <output-file>                             Write output to this file (overwrites if exists)
  --minify                                                    Output compact/minified JSON (overrides most formatting)
  --time                                                      Write elapsed formatting time to stdout
  --wide                                                      Adjust display width for East Asian (CJK) wide characters
  --eol, --JsonEolStyle <Crlf|Default|Lf>                     Line ending style
  -l, --length, --MaxTotalLineLength <length>                 Max characters per line (incl. indent)
  -i, --inline, --MaxInlineComplexity <inline>                Max nesting depth allowed inline on one line
  -a, --array, --MaxCompactArrayComplexity <array>            Max nesting for compact arrays (multiple items/row)
  -t, --MaxTableRowComplexity, --table <table>                Max nesting for table-style formatting
  --MaxPropNamePadding, --prop-padding <prop-padding>         Max number of spaces to line up property values
  --colon-before, --ColonBeforePropNamePadding                Place colon before (instead of after) property-name 
                                                              padding
  --table-comma, --TableCommaPlacement                        Comma position in table rows
  <AfterPadding|AP|BeforePadding|BeforePaddingExceptNumbers|
  BP|BPEN>
  --min-array-items, --MinCompactArrayRowItems                Minimum items per row for compact arrays
  <min-array-items>
  --always-expand, --AlwaysExpandDepth <always-expand>        Force expansion from root down to this depth (-1=no force)
  --nested-pad, --NestedBracketPadding                        Space inside []/{} for complex (nested) containers
  --simple-pad, --SimpleBracketPadding                        Space inside []/{} for simple (primitive-only) containers
  --colon-pad, --ColonPadding                                 Space after colon
  --comma-pad, --CommaPadding                                 Space after comma
  --comment-pad, --CommentPadding                             Space between comment and value
  --number-align, --NumberListAlignment                       Number column alignment
  <D|Decimal|L|Left|N|Normalize|R|Right>
  --indent, --IndentSpaces <indent>                           Spaces per indent level
  --tabs, --UseTabToIndent                                    Use tabs instead of spaces for indent
  --prefix, --PrefixString <prefix>                           Prefix every output line with this string
  -c, --CommentPolicy, --comments                             How to handle // or /* */ comments
  <E|P|Preserve|R|Remove|TreatAsError>
  --blanks, --PreserveBlankLines                              Keep blank lines from input
  --AllowTrailingCommas, --trailing                           Permit trailing commas in arrays/objects from input
  -?, -h, --help                                              Show help and usage information
  --version                                                   Show version information

FracturedJson library version: 5.0.0.0

Config file

You can specify some or FracturedJsonOptions in a config file. You can still override specific values from the command line if you wish. The names must match the long FracturedJsonOptions property names, not the shorter commandline aliases. Case case doesn't matter, and comments are allowed.

You can explicitly specify a config file with the --config switch and a file path.

If you don't provide one, fracjson will look for a file named one of: .fracturedjson, .fracturedjson.jsonc, .fracturedjson.json. It will start in the input file's location and walk up the directory hierarchy until one is found. If input is coming from stdin instead of a file, the current working directory will be used at the starting place.

You can use --no-config to prevent loading a default file.

East Asian Full Width

Use the --wide switch to force fracjson to account for East Asian Full Width characters when aligning parts of the document. (It's a little bit slower when enabled.)

Clone this wiki locally