---
title: "Prettier"
description: "Prettier automatically formats code to ensure consistency and readability across your project."
date: "2025-10-02"
lastUpdated: "2025-11-16"
tags: ["prettier","code","formatting","frontend"]
canonical: "/learn/guides/project/prettier"
---

import { Code } from '@astrojs/starlight/components'
import Source from './.prettierrc.json?raw'
import PackageManagers from '~/components/PackageManagers.astro'

## Installation

See the [official documentation](https://prettier.io/docs/en/install).

<PackageManagers pkg="prettier" flags="--dev --exact" />

## Settings

These are basic prettier settings (`.prettierrc.json`).

<Code code={Source} lang="json" title=".prettierrc.json" wrap />

Create an ignore file (`.prettierignore`):

```text
build
dist
coverage
analysis
```

## Usage

and here is a script to run prettier on a javascript project:

```sh
# File: package.json

"format": "prettier \"./**/*.{html,css,js,jsx,ts,tsx,md,mdx,json}\" --write --cache --log-level=warn",
```

More [CLI docs](https://prettier.io/docs/en/cli)

[Integration](https://prettier.io/docs/en/integrating-with-linters) with a linter
