Skip to content
Latchkey

Prettier printWidth: Line Length

printWidth sets the column Prettier aims to keep lines within, defaulting to 80.

printWidth is the single option teams most often change. It is a target, not a hard cap, but it shapes nearly every wrapping decision.

What it does

printWidth tells Prettier the line length to fit code within when deciding whether to break expressions, arguments, and objects onto multiple lines. The default is 80. It is a guideline: Prettier will exceed it when no good break exists (for example a long string literal or URL).

Common usage

.prettierrc.json
// .prettierrc.json
{ "printWidth": 100 }

// or per CLI
// prettier --print-width 100 --check .

Options

SettingWhat it does
printWidth (default 80)Target line length in columns
--print-width <n>Set it on the CLI
Common values80, 100, 120 depending on team preference

In CI

Set printWidth in committed config, never rely on the CLI flag in one place and config in another, or local and CI runs will format differently. A change to printWidth reflows large parts of the codebase, so make it a dedicated commit and run prettier --write . once to avoid a noisy --check failure.

Common errors in CI

The usual CI symptom is "Code style issues found" after someone changed printWidth in an editor setting but not the committed config, so files reflow only on their machine. Keep the value in .prettierrc and remove editor-level overrides. Note printWidth does not hard-truncate long strings; do not expect lines to always be under the limit.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →