Skip to main content

Formatters

ESLint formatters control the appearance of linting results in the CLI. ESLint comes with several built-in formatters and supports third-party formatters as well.

Using Formatters

Specify a formatter using the --format or -f flag:
The default formatter is stylish, which provides human-readable output with colors.

Built-in Formatters

ESLint includes four built-in formatters:

stylish

Default formatterHuman-readable with colors and context

json

JSON outputFor programmatic processing

json-with-metadata

JSON + metadataIncludes rule metadata

html

HTML reportVisual browser-based report

stylish (Default)

The stylish formatter provides clean, readable output with color coding:
Colors can be controlled with --color and --no-color flags, or via environment variables like FORCE_COLOR, NO_COLOR, or NODE_DISABLE_COLORS.

json

Outputs JSON-serialized results for programmatic processing:
Use the JSON formatter when:
  • Building CI/CD integrations
  • Creating custom reporting tools
  • Processing results programmatically
  • Storing results in databases

json-with-metadata

Extends the JSON formatter with rule metadata:

html

Generates an interactive HTML report:
Interactive HTML report with:
  • Color-coded violations
  • Sortable columns
  • Filterable results
  • File grouping
  • Rule descriptions
  • Click-to-expand details
  • Summary statistics
  • Professional styling
The HTML formatter is designed for viewing in a browser and includes all necessary CSS and JavaScript inline.

Saving Output to File

Custom Formatters

You can create and use custom formatters:

Local Custom Formatter

1

Create formatter file

my-formatter.js
2

Use the formatter

NPM Package Formatter

1

Install formatter

2

Use the formatter

ESLint automatically adds the eslint-formatter- prefix if not present.

Formatter Context

Formatters receive two arguments:

Results Array

Context Object

Comparing Formatters

Best: stylish
  • Human-readable
  • Color-coded
  • Quick scan of issues
  • Shows line numbers
Beautiful formatter with colors and context:
Features:
  • Syntax highlighting
  • Code context
  • File hyperlinks (VS Code, WebStorm)
  • Summary statistics
Table-based output:
Features:
  • Tabular layout
  • Column alignment
  • Clear separation
  • Sortable data
GitLab Code Quality format:
Use for:
  • GitLab CI/CD integration
  • Code Quality widgets
  • Merge request reports
Shows code context with pointers:
Features:
  • Code snippets
  • Error pointers
  • Detailed context
  • Multiple lines

Example Workflow

Best Practices

  • Development: stylish for readability
  • CI/CD: json for processing
  • Reports: html for stakeholders
  • Analysis: json-with-metadata for tooling
Output to console AND file:

Command Line

CLI options including —format

Integrations

Editor and build tool integrations

Configuration

Configure ESLint for your project

Core Concepts

Understanding ESLint fundamentals