npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@raphaellcs/code-formatter

v1.0.0

Published

A simple code formatter for JSON, CSS, and HTML

Readme

@raphaellcs/code-formatter

A simple and easy-to-use code formatter for JSON, CSS, HTML, JavaScript, and TypeScript.

Features

  • 🎨 Format multiple file types (JSON, CSS, HTML, JS, TS)
  • 📁 Batch format files in directories
  • 🔍 Check if files are properly formatted
  • ⚙️ Customizable formatting options (indentation, width, quotes)
  • 🚀 Fast and lightweight

Installation

# Use with npx (no installation needed)
npx @raphaellcs/code-formatter --help

# Or install globally
npm install -g @raphaellcs/code-formatter

Usage

Format a Single File

# Format a JSON file
npx @raphaellcs/code-formatter format --file data.json

# Format and save to a new file
npx @raphaellcs/code-formatter format --file input.json --output output.json

# Format with custom indentation (4 spaces)
npx @raphaellcs/code-formatter format --file code.js --spaces 4

# Format with tabs
npx @raphaellcs/code-formatter format --file code.css --tab

Batch Format Files in Directory

# Format all JSON and CSS files in current directory
npx @raphaellcs/code-formatter batch --directory .

# Format recursively (including subdirectories)
npx @raphaellcs/code-formatter batch --directory . --recursive

# Format specific file types
npx @raphaellcs/code-formatter batch --directory . --extensions json,css,html

# Format with custom options
npx @raphaellcs/code-formatter batch --directory src --recursive --tab --width 100

Check if Files are Formatted

# Check a single file
npx @raphaellcs/code-formatter check --file data.json

# Check all files in directory
npx @raphaellcs/code-formatter check --directory . --recursive

# The command exits with code 1 if files need formatting

Options

Format Command

  • -f, --file <path> - File path to format
  • -o, --output <path> - Output file path (default: overwrite original)
  • -w, --width <number> - Line width (default: 80)
  • -s, --spaces <number> - Number of spaces for indentation (default: 2)
  • --tab - Use tabs instead of spaces
  • --no-semi - No semicolons (JavaScript only)
  • --single-quote - Use single quotes instead of double
  • --check - Check if file is formatted without modifying

Batch Command

  • -d, --directory <path> - Directory path (default: current directory)
  • -e, --extensions <extensions> - File extensions (comma-separated, default: json,css,html,htm,js,ts)
  • -r, --recursive - Format files recursively in subdirectories
  • -w, --width <number> - Line width (default: 80)
  • -s, --spaces <number> - Number of spaces for indentation (default: 2)
  • --tab - Use tabs instead of spaces
  • --check - Check if files are formatted without modifying

Examples

Example 1: Format a Messy JSON File

Input file (data.json):

{"name":"John","age":30,"city":"New York"}

Command:

npx @raphaellcs/code-formatter format --file data.json

Output file (data.json):

{
  "name": "John",
  "age": 30,
  "city": "New York"
}

Example 2: Format CSS with Tabs

Input file (style.css):

body{background-color:#fff;color:#333;margin:0;padding:0}

Command:

npx @raphaellcs/code-formatter format --file style.css --tab

Output file (style.css):

body {
	background-color: #fff;
	color: #333;
	margin: 0;
	padding: 0;
}

Example 3: Batch Format All JS Files

$ npx @raphaellcs/code-formatter batch --directory src --extensions js --recursive
✔ Found 12 file(s) to format...

✔ Formatting app.js... Done
✔ Formatting utils.js... Done
✔ Formatting index.js... Done
...

✔ Formatted 12 file(s) successfully!

Example 4: Check Files Before Commit

# Check if files need formatting (for CI/CD)
npx @raphaellcs/code-formatter check --directory . --recursive
✔ Checked 24 file(s). All files are formatted!

# Or if files need formatting:
✖ Checked 24 file(s). 3 need formatting.

Supported File Types

  • ✅ JSON (.json)
  • ✅ CSS (.css)
  • ✅ HTML (.html, .htm)
  • ✅ JavaScript (.js, .jsx)
  • ✅ TypeScript (.ts, .tsx)

Use Cases

  • 📦 Preparing JSON configuration files
  • 🎨 Cleaning up messy CSS
  • 📄 Formatting HTML documents
  • 🔧 JavaScript/TypeScript code formatting
  • 🔄 CI/CD pre-commit hooks
  • 📊 Project-wide code style enforcement

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

MIT

Author

Dream Heart 🌙

Links