Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
Basic Setup
- Install the Prettier VS Code extension
- Enable Format on Save in VS Code settings
- Enable Format on Paste if you want pasted code to be formatted automatically
Add these settings to your settings.json:
{
"editor.formatOnSave": true,
"editor.formatOnPaste": true
}
Running Prettier on All Files
To format all files in a project at once:
- Create a
.prettierrcfile in your project root:
{
"tabWidth": 2,
"useTabs": false,
"semi": false
}
- Run:
npx prettier -w .
Setting Up Prettier with ESLint for React
For React development, set up both ESLint and Prettier:
- Install the ESLint extension
- Install dependencies:
yarn add babel-eslint
yarn add eslint-config-airbnb
yarn add eslint-plugin-jsx-a11y
yarn add eslint-plugin-react
- Create
.eslintrc.jsonin your project root:
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": ["react", "jsx-a11y", "import"]
}
- Install Prettier integration:
npm install -g prettier-eslint --save-dev
- Add to VS Code settings:
{
"editor.formatOnSave": true,
"javascript.format.enable": false,
"prettier.eslintIntegration": true
}
Fixing HTML Formatting Issues
If Prettier is messing up your HTML formatting, you can use VS Code’s default HTML formatter instead:
{
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
}
}
Formatting Astro Files
Prettier doesn’t understand Astro syntax by default. To fix this:
- Install the Astro Prettier plugin:
npm install -D prettier-plugin-astro
-
Make sure Editor: Format On Save and Editor: Format On Paste are enabled in VS Code settings
-
Important: Make sure you open the specific project folder in VS Code, not a parent folder. Opening a parent folder may prevent the Astro formatter from working.