Directives let you control how the beautifier processes specific sections of a file, directly from within that file’s comments. You can instruct the beautifier to ignore a block entirely, or to parse it and preserve its existing formatting.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/beautifier/js-beautify/llms.txt
Use this file to discover all available pages before exploring further.
Directive format
Directives are placed in comments using the format:- JavaScript and CSS:
/* beautify {name}:{value} */ - HTML:
<!-- beautify {name}:{value} -->
start marker and an end marker that define the affected region.
Ignore directive
Theignore directive tells the beautifier to treat a section as literal text. The content inside the markers is not parsed — it passes through exactly as written.
Use ignore when the content between the markers is not valid syntax in the current language, such as a foreign DSL or template syntax that would break the parser.
JavaScript example
HTML example
CSS example
Preserve directive
Thepreserve directive tells the beautifier to parse the section as normal but keep the existing formatting exactly as written. Unlike ignore, the content must be valid syntax — the beautifier reads it but does not reformat it.
Use preserve when the code between the markers is syntactically valid but intentionally formatted in a way you want to keep, such as a vertically aligned object literal.
JavaScript example
HTML example
Choosing between ignore and preserve
ignore | preserve | |
|---|---|---|
| Content must be valid syntax | No | Yes |
| Content is parsed | No | Yes |
| Formatting is changed | No | No |
| Works in JavaScript | Yes | Yes |
| Works in HTML | Yes | Yes |
| Works in CSS | Yes | No |
ignore when the content would cause a parse error. Use preserve when the content is valid code that you want to keep formatted a specific way.