Socket
Book a DemoInstallSign in
Socket

@herb-tools/formatter

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@herb-tools/formatter

Auto-formatter for HTML+ERB templates with intelligent indentation, line wrapping, and ERB-aware pretty-printing.

latest
Source
npmnpm
Version
0.7.4
Version published
Weekly downloads
4.7K
2.05%
Maintainers
1
Weekly downloads
 
Created
Source

Herb Formatter

Package: @herb-tools/formatter

[!WARNING] Experimental Preview This formatter is currently in experimental preview. While it works for many common cases, it may potentially corrupt files in edge cases. Only use on files that can be restored via git or other version control systems.

Auto-formatter for HTML+ERB templates with intelligent indentation, line wrapping, and ERB-aware pretty-printing.

Perfect for format-on-save in editors and formatting verification in CI/CD pipelines. Transforms templates into consistently formatted, readable code while preserving all functionality.

Installation

Global Installation

:::code-group

npm install -g @herb-tools/formatter
pnpm add -g @herb-tools/formatter
yarn global add @herb-tools/formatter
bun add -g @herb-tools/formatter

:::

Then run directly:

herb-format template.html.erb

One-time Usage

For occasional use without installing:

npx @herb-tools/formatter template.html.erb

Project Installation

:::code-group

npm add -D @herb-tools/formatter
pnpm add -D @herb-tools/formatter
yarn add -D @herb-tools/formatter
bun add -D @herb-tools/formatter

:::

After installing as a dev dependency, add format scripts to your package.json:

{
  "scripts": {
    "herb:format": "herb-format",
    "herb:format:check": "herb-format --check"
  }
}

Then run the scripts:

:::code-group

npm run herb:format
npm run herb:format:check
pnpm herb:format
pnpm herb:format:check
yarn herb:format
yarn herb:format:check
bun run herb:format
bun run herb:format:check

:::

Usage

Command Line

Basic usage:

herb-format
herb-format template.html.erb
herb-format templates/

Options

Check Mode:

# Check if files are formatted without modifying them
herb-format --check template.html.erb

# Check all files in current directory
herb-format --check

Input Sources:

# Format specific file
herb-format templates/index.html.erb

# Format all .html.erb files in directory
herb-format templates/

# Format all .html.erb files in current directory (default)
herb-format

# Format from stdin
cat template.html.erb | herb-format

Help and Version:

# Show help
herb-format --help

# Show version information
herb-format --version

FAQs

Package last updated on 26 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts