@devtools-at/json-formatter
v1.0.2
Published
Format and beautify JSON with syntax validation
Maintainers
Readme
JSON Formatter
Online Tool
Try JSON Formatter online at DevTools.at →
Use this tool directly in your browser - no installation required:
- No registration needed
- Works instantly in your browser
- Your data never leaves your device (100% client-side)
- Available in 20+ languages
- Free forever
What is JSON Formatter?
Format and beautify JSON with syntax validation. This is a standalone TypeScript/JavaScript implementation that you can use in your own projects.
Features
- Zero Dependencies - Lightweight with no external dependencies
- TypeScript Support - Full type definitions included
- Browser & Node.js - Works in both environments
- UTF-8 Support - Handles international characters correctly
Usage
import { format, minify, validate } from '@devtools-at/json-formatter';
const messyJson = '{"name":"John","age":30,"city":"New York"}';
// Format with 2-space indentation
const formatted = format(messyJson, { indent: 2 });
console.log(formatted);
// {
// "name": "John",
// "age": 30,
// "city": "New York"
// }
// Minify JSON
const minified = minify(formatted);
console.log(minified); // {"name":"John","age":30,"city":"New York"}
// Validate JSON
console.log(validate(messyJson)); // { valid: true }
console.log(validate('{invalid}')); // { valid: false, error: "..." }API Reference
Core Functions
The source code in src/index.ts contains the core implementation. You can copy and use these functions directly in your project.
Related Tools
Check out our other free developer tools at DevTools.at:
| Tool | Description | |------|-------------| | JSON Formatter | Format and beautify JSON | | Base64 Encoder | Encode/decode Base64 | | Hash Generator | Generate MD5, SHA hashes | | UUID Generator | Generate random UUIDs | | Password Generator | Create secure passwords | | JWT Decoder | Decode JSON Web Tokens | | URL Encoder | Encode URL parameters | | Regex Tester | Test regular expressions |
Browse all 100+ free developer tools →
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see the LICENSE file for details.
