Registry / devops / prettier-custom-html-indent

prettier-custom-html-indent

JSON →
library3.3.2jsnpmunverified

A fork of Prettier (v3.3.2) that adds custom indentation for HTML attributes, which is impossible to achieve via official plugins or options. This package allows setting a specific indentation width for HTML attributes (htmlAttributeIndent) and defining attributes that should stay on the same line as the tag (sameLineAttributes). It supports JavaScript, TypeScript, JSX, CSS, HTML, Vue, Angular, and more. The fork follows Prettier's release cadence and is compatible with Prettier's existing options and plugins. It is actively maintained as a separate package.

npm install prettier-custom-html-indent
INSTALL
IMPORT
SIG · PRETTIER-CUSTOM-HT
P
prettier-custom-html-indent
devopsjavascriptv3.3.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

prettier
import prettier from 'prettier-custom-html-indent'
const prettier = require('prettier')
This package replaces prettier. Use the package name 'prettier-custom-html-indent' for all imports.
format
import { format } from 'prettier-custom-html-indent'
import { format } from 'prettier'
All exports are identical to prettier, but must be imported from 'prettier-custom-html-indent'.
resolveConfig
import { resolveConfig } from 'prettier-custom-html-indent'
import { resolveConfig } from 'prettier'
Same as above: use the forked package name.

Formats HTML with custom attribute indentation (2 spaces) and keeps 'id' on the same line as the tag.

import prettier from 'prettier-custom-html-indent'; const code = `<div class="container" id="main" style="display:block">\n <span>Hello</span>\n</div>`; const formatted = prettier.format(code, { parser: 'html', htmlAttributeIndent: 2, sameLineAttributes: ['id'], }); console.log(formatted); // Output: // <div class="container" // id="main" // style="display:block" // > // <span>Hello</span> // </div>
prettier --version
Debug
Known issues
breakingThis package is a fork of Prettier. Do NOT use it alongside the original Prettier package; only one should be installed.
fix
Uninstall prettier and install prettier-custom-html-indent.
affects: all
deprecatedThe 'htmlAttributeIndent' option is not standard Prettier; it may not be supported in future versions if upstream Prettier changes its API.
fix
Monitor the package for updates; consider pinning the version.
affects: >=3.0.0
gotchaOptions 'htmlAttributeIndent' and 'sameLineAttributes' only work with HTML/JSX parsers; they are ignored for other languages.
fix
Ensure you are formatting HTML files or set parser: 'html' or 'babel' for JSX.
affects: all
Errors
Common errors & fixes
Cannot find module 'prettier'
You have installed prettier-custom-html-indent but are importing from 'prettier'.
fix
Change import to 'prettier-custom-html-indent'.
Error: Invalid option 'htmlAttributeIndent'. Allowed options: ...
You are using the original prettier package instead of the fork.
fix
Install and import from 'prettier-custom-html-indent'.
TypeError: prettier.format is not a function
Using default import incorrectly with CommonJS require.
fix
Use: const prettier = require('prettier-custom-html-indent'); or import prettier from 'prettier-custom-html-indent'.
Upgrade
Version history
3.3.2latest on npm
Audit
Dependencies
prettierrequiredThis is a fork of prettier, but published as a separate package. It does not require the original prettier as a dependency, but users should not install both.
Agent activity
6 hits · last 30 days
node
6
Resources
prettier-custom-html-indent — npm install prettier-custom-html-indent · libregistry