Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.NET based CLI tool for pretty-printing JSON files. Focus on using a small memory footprint regardless of JSON filesize

License

Notifications You must be signed in to change notification settings

nattfalk/json-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonFormat

A high-performance command-line tool for formatting (pretty-printing) large JSON files while maintaining low memory usage.

Features

  • Memory Efficient: Processes very large JSON files without loading them entirely into memory
  • Fast Processing: Optimized for speed with parallel processing support
  • Flexible Options: Configurable buffer sizes, comment handling, and formatting options
  • Cross-Platform: Built on .NET 9.0, runs on Windows, macOS, and Linux

Installation

Prerequisites

  • .NET 9.0 SDK or later

Build from Source

git clone https://github.com/nattfalk/JsonFormat.git
cd JsonFormat/src
dotnet build -c Release

Run

dotnet run -- [options] <json-files>

Or after building:

./bin/Release/net9.0/JsonFormat [options] <json-files>

Usage

JsonFormat [options] <json-files>

Options

  • --help: Show help information
  • --buffer-size <size>: Set buffer size in bytes (default: 65536, minimum: 1024)
  • --allow-trailing-commas: Allow trailing commas in JSON
  • --skip-comments: Skip JSON comments during processing
  • --no-parallel: Disable parallel processing for multiple files
  • --overwrite: Overwrite input files instead of creating .formatted.json files
  • --max-depth <depth>: Set maximum parsing depth (0 for unlimited, default: 0)

Examples

Format a single JSON file:

JsonFormat data.json

Format multiple files with custom buffer size:

JsonFormat --buffer-size 131072 file1.json file2.json file3.json

Format with trailing commas allowed and overwrite original files:

JsonFormat --allow-trailing-commas --overwrite data.json

Process files sequentially (no parallel processing):

JsonFormat --no-parallel *.json

Performance

JsonFormat is designed to handle very large JSON files efficiently:

  • Uses streaming JSON parsing to minimize memory usage
  • Configurable buffer sizes for optimal performance
  • Parallel processing support for multiple files
  • Low memory footprint even with gigabyte-sized JSON files

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Requirements

  • .NET 9.0 or later

Changelog

v1.0.0

  • Initial release
  • Basic JSON formatting functionality
  • Memory-efficient processing
  • Parallel processing support
  • Configurable options

About

.NET based CLI tool for pretty-printing JSON files. Focus on using a small memory footprint regardless of JSON filesize

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages