prettier-ignore: Skip Formatting Inline
A prettier-ignore comment leaves the following AST node exactly as written.
Sometimes hand-aligned data or a specific layout must survive formatting. The inline ignore comment exempts just that node, not the whole file.
What it does
Prettier looks for a prettier-ignore comment immediately before a node and leaves that node untouched. The comment form depends on the language: // prettier-ignore in JavaScript and TypeScript, {/* prettier-ignore */} in JSX, <!-- prettier-ignore --> in Markdown and HTML, and # prettier-ignore in YAML.
Common usage
// prettier-ignore
const matrix = [
1, 0, 0,
0, 1, 0,
0, 0, 1,
];
{/* prettier-ignore */}
<div className="keep spacing" />Options
| Language | Comment form |
|---|---|
| JavaScript / TypeScript | // prettier-ignore |
| JSX | {/* prettier-ignore */} |
| CSS / SCSS / Less | /* prettier-ignore */ |
| Markdown / HTML | <!-- prettier-ignore --> |
| YAML | # prettier-ignore |
In CI
A prettier-ignore comment exempts the node from both --write and --check, so CI will not flag a deliberately hand-formatted block. Keep these rare and commented with why, since they are easy to leave stale when the surrounding code changes.
Common errors in CI
If CI still reflows the block, the comment is not directly before the node (a blank line or another statement broke the adjacency) or you used the wrong comment form for the language. In Markdown, the comment must be its own block, not inline in a paragraph.