"Leading-Comma JSON Formatter"
Find a file
2025-12-02 08:09:58 +00:00
.devenv Examples and argparsing 2025-12-02 01:29:40 -05:00
app Examples and argparsing 2025-12-02 01:29:40 -05:00
src lcjf 2025-11-29 15:43:15 -05:00
test lcjf 2025-11-29 15:43:15 -05:00
.devenv.flake.nix lcjf 2025-11-29 15:43:15 -05:00
.gitignore Initial commit 2025-11-29 20:13:50 +00:00
devenv.lock lcjf 2025-11-29 15:43:15 -05:00
devenv.nix lcjf 2025-11-29 15:43:15 -05:00
devenv.yaml lcjf 2025-11-29 15:43:15 -05:00
example.json Examples and argparsing 2025-12-02 01:29:40 -05:00
lcjf.cabal Examples and argparsing 2025-12-02 01:29:40 -05:00
LICENSE Initial commit 2025-11-29 20:13:50 +00:00
README.md Update README.md 2025-12-02 08:09:58 +00:00

lcjf

"Leading-Comma JSON Formatter"

Why

Leading commas are the superior way to format JSON, dictionaries, records, etc. You either know it or are in denial of it.

This simple little program lets you input JSON via stdin or a pipe, then it spits out properly-formatted JSON with leading commas. The right way.

It turns this (from jq):

{
  "api_version": "2.1.0",
  "debug": null,
  "features": {
    "beta": [
      "new_fancy_thing"
    ],
    "deprecated": {},
    "stable": []
  },
  "users": [
    {
      "active": false,
      "email": "bob@example.com",
      "id": 1,
      "metadata": {
        "created_at": "2024-06-22T14:45:00Z",
        "last_login": "2024-11-01T09:00:00Z",
        "preferences": {
          "language": "en-US",
          "notifications": false,
          "theme": "dark"
        }
      },
      "name": "Bob Smith"
    }
  ]
}

Into this beauty:

{ "api_version": "2.1.0"
, "debug": null
, "features":
  { "beta":
    [ "new_fancy_thing"
    ]
  , "deprecated": { }
  , "stable": [ ]
  }
, "users":
  [ { "active": false
    , "email": "bob@example.com"
    , "id": 1
    , "metadata":
      { "created_at": "2024-06-22T14:45:00Z"
      , "last_login": "2024-11-01T09:00:00Z"
      , "preferences":
        { "language": "en-US"
        , "notifications": false
        , "theme": "dark"
        }
      }
    , "name": "Bob Smith"
    }
  ]
}

Much better.

Supports reading from stdin, argument-strings, or a file, and outputs to stdout or a file. All the stuff you'd expect.

Installing

Until I push this to Hackage and actually set up pre-built binaries, best way to install and use this is to clone it and cabal install it. Make sure ~/.local/bin is on your path.

Contributing

Honestly, I don't know how that's going to work now with my own Forgejo instance here. I don't even know how creating Issues works on here at the moment. Probably best to just yell at me on social media and I'll do something eventually maybe.

AI Disclaimer

This program was put together with the work of a Claude AI agent. My opinions on AI as a whole are largely negative, and I refrain from using it for matters of creative industries. I normally only use it with software development for research assistance, minimizing its actual writing of code.

This program, however, was almost entirely made with the Claude Code AI agent. To me, this is a silly little project that is unlikely to gain usage, even from myself, and I didn't care about the time to write an program for argument parsing, Aeson parsing and pretty printing.