https://github.com/iaseth/fj
A command-line JSON formatter.
https://github.com/iaseth/fj
command-line-tool formatter javascript json nodejs typescript
Last synced: about 2 months ago
JSON representation
A command-line JSON formatter.
- Host: GitHub
- URL: https://github.com/iaseth/fj
- Owner: iaseth
- License: mit
- Created: 2024-11-14T09:37:55.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-03-31T11:41:15.000Z (6 months ago)
- Last Synced: 2025-07-13T23:43:45.811Z (3 months ago)
- Topics: command-line-tool, formatter, javascript, json, nodejs, typescript
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/fj-cli
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# fj - JSON Formatter CLI
`fj` is a command-line utility for formatting JSON files with customizable indentation and output options. It allows users to specify indentation styles, choose output modes, and process multiple JSON files efficiently.
## Features
- **Indentation Options:** Use tabs or spaces (1, 2, or 4 spaces).
- **Output Modes:**
- **PRINT:** Display formatted JSON in the console (default).
- **ASK:** Prompt for a filename to save the formatted JSON.
- **FJ:** Save the formatted JSON with a `.fj.json` extension.
- **REPLACE:** Overwrite the original file.
- **End with Newline:** Optionally append a newline character.
- **Batch Processing:** Format multiple JSON files in one command.## Installation
Install `fj` globally using npm:
```bash
npm i -g fj-cli
```## Usage
Run `fj` from the command line with options and file paths:
```bash
fj [options] ...
```### Options
- **Indentation:**
- `MIN`: Minify JSON (no spaces).
- `S1` or `1S`: 1-space indentation.
- `S2` or `2S`: 2-space indentation.
- `S4` or `4S`: 4-space indentation.
- `TAB` or `TABS`: Tab indentation.
- **Output Modes:**
- `PRINT`: Print formatted JSON to console.
- `ASK`: Prompt for a filename to save.
- `FJ`: Save as `.fj.json`.
- `REPLACE`: Overwrite the original file.
- **Additional:**
- `ENL`: Append a newline at the end.### Examples
- Format `data.json` using 2 spaces and print to console:
```bash
fj S2 data.json
```
- Format `data.json` using tabs and save as `data.fj.json`:
```bash
fj TAB FJ data.json
```
- Minify `data.json` and overwrite the original file:
```bash
fj MIN REPLACE data.json
```
- Format multiple files with 4 spaces and append a newline:
```bash
fj S4 ENL file1.json file2.json
```## License
This project is licensed under the MIT License.
For more details, visit [https://github.com/iaseth/fj](https://github.com/iaseth/fj).