Follow these steps:

  1. CTRL + SHIFT + P
  2. Format Document (in pop-up bar)
  3. Select Format Document
  4. Select Configure Default Formatter...
  5. Select Prettier - Code formatter

To enable Format On Save

  1. CTRL + SHIFT + P
  2. Preferences Open Settings (UI) (in pop-up bar)
  3. Type Format On Save
  4. Enable Format On Save if it is not checked

Done!

Answer from Yakupguly Malikov on Stack Overflow
🌐
Avenuecode
blog.avenuecode.com › how-to-integrate-prettier-and-eslint-in-vscode-and-react
How to Integrate Prettier and ESLint in VSCode and React
October 12, 2022 - $ npm install -D eslint prettier eslint-config-prettier # or $ yarn add -D eslint prettier eslint-config-prettier · Now, run the ESLint init script to initialize the linter in your project with custom configurations. ... ? How would you like to use ESLint? > To check syntax, find problems, and enforce code style ? What type of modules does your project use? > JavaScript modules (import/export) ? Which framework does your project use? > React ?
🌐
DEV Community
dev.to › mendoza › how-i-set-eslint-and-prettier-for-a-react-project-on-vs-code-3hp9
How to set Eslint and Prettier for a React project on vs code - DEV Community
May 11, 2021 - So we need a file on our react project's root called ".eslintrc.js", you will probably have it because of the commands we ran, but we are going to make some little changes, just adding prettier on our extends and our plugins.
🌐
Sebastian Weber
doppelmutzi.github.io › react-eslint-prettier-vscode-2020
Efficient Code Analyzing and Formatting (for React) with ESLint, Prettier and VSCode – 2020 Edition
February 24, 2020 - TLTR; With this setup you can integrate ESLint with Prettier in a way that code formatting is turned off for ESLint (eslint-config-prettier) and runs Prettier as an ESLint rule (eslint-plugin-prettier. eslint-plugin-standard and eslint-plugin-react are two of the supported plugins.
🌐
DEV Community
dev.to › topeogunleye › building-a-modern-react-app-with-vite-eslint-and-prettier-in-vscode-13fj
Supercharge Your React Development with Vite, ESLint, and Prettier in VSCode - DEV Community
July 30, 2024 - Boost your React projects by combining Vite’s fast development server, ESLint’s strong linting features, and Prettier’s consistent formatting. With these tools, your VSCode becomes a productivity powerhouse.
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
prettier-vscode · Built-in support · Got more?Send a PR · See others · Regularly used by: More than 83% of respondents to State of JS 2021. More than 70% of respondents to State of JS 2020. More than 9.9 million dependent repositories on GitHubCheck Them Out ·
Find elsewhere
🌐
LinkedIn
linkedin.com › pulse › config-eslint-prettier-vs-code-react-js-anurag-kumar
Config Eslint and Prettier in VS Code for React js
June 19, 2023 - To do this, access the extensions section of VSCode by pressing "Ctrl + Shift + X" and search for "Eslint" and "Prettier — Code formatter" extensions. Install both of them to ensure their functionality.
🌐
Medium
medium.com › @crbodarya05 › data-how-to-set-up-prettier-in-a-react-app-the-right-way-f5fe45d40bf4
Set Up Prettier in React (Complete Beginner Guide) | Medium
April 7, 2025 - Learn how to set up Prettier in your React app the right way. Includes installation, config, VS Code integration, and formatting tips for cleaner code.
🌐
Medium
andrebnassis.medium.com › setting-prettier-on-a-react-typescript-project-2021-f9f0d5a1d6b0
Setting Prettier on a React Typescript project (2022) | by André Borba Netto Assis | Medium
January 20, 2022 - Create a ‘settings.json’ file inside .vscode/ folder and insert the follow code on it: ... Done! Now every file saved will be formatted within the Prettier formatting rules.
🌐
Readwriteexercise
readwriteexercise.com › posts › setting-up-create-react-app-vs-code-eslint-prettier
Setting up Create React App, VS Code, ESLint, and Prettier - Read, Write, Exercise
In this post we’ll walk through how to setup a new or existing React project to automatically lint and format code. We’ll be using VS Code as our editor, Create React App (CRA) to create our React application, and ESLint and Prettier to do the actual code formatting and linting.
🌐
DEV Community
dev.to › tsamaya › eslint-and-prettier-configuration-for-react-project-2gij
ESLint and Prettier configuration for React project - DEV Community
March 21, 2023 - Prettier is an opinionated code formatter. It ensures a consistent style by parsing your code and re-writing it with its rules. If you are using VScode, and already have the ESLINT and PRETTIER plugins, as you are goigng to change the configuration ...
Top answer
1 of 3
7

I'm more of the "edit the JSON" type of user of VSCode, and the answer from Masud was confusing to me because of that. It did push me in the right direction and I want to share for other like myself, more familiar with the .vscode/settings.json(s) than with that graphical Settings Editor.

settings.json edits - add these:

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true
}

.prettierrc edit or add a file by that name at the root of your project for any custom settings. Here are some of my favs:

{
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "none"
}

Then, you can sanity check against those rules. I just added a trailing comma in an object block (in a Styles block in the sample Expo tsx component, in my case - brand new project) and see it removed on save... Then, remove the trailingComma rule, save, and try the comma again and see that the comma stays.

2 of 3
4

Regarding Auto Code Formatting:

For anyone starting out with VSCode - Expo, React-Native devs or having some issues with code formatting, please find below the simplest solution I could find (ESLint is a bit confusing / complex unless you are fairly familiar) - link to Expo guide is here if you would really like to do this (https://docs.expo.dev/guides/using-eslint/) - It is a bit complicated if you are just starting out and I find ESLint to cause too much bloat messaging on my code editor screen, especially now that there are things such as copilot etc.


[Instructions] Simply set up Prettier (no ESLint):

  1. Add 'Prettier - Code Formatter' extension in VSCode and enable it
  2. Go to the VSCode settings to set both the User and Workspace fields for a) Editor: Default Formatter to "Prettier - Code formatter", then b) check to enable Format on Save (I also checked Notebook > Format on Save).

Now get to Coding!!!


Some Next Steps:

You can check out the Expo Guide (or similar) for further best practices but it will take some time to get it all setup.

Prettier should already auto-format on save and you can further configure it by adding a .prettierrc file at the root of your project and following https://github.com/expo/expo/tree/main/packages/eslint-config-universe#customizing-prettier which should override the default settings you have set up for all your projects.

You can later setup linting as well which is generally more useful down the line for when working with remote/shared repositories (ie: they contain explanations for the correction, etc.). Causes a bit of bloat but it's quite helpful for navigating a new team / codebase (ex Amazon SDE) to understand the style guidelines being used, fixing an entire project programmatically via a script etc. with ESLint.

🌐
DEV Community
dev.to › frontendbytes › setting-up-eslint-and-prettier-in-your-react-project-with-webpack-and-babel-continued-5ad1
Setting Up ESLint and Prettier in Your React Project with Webpack and Babel (Continued) - DEV Community
April 14, 2025 - Install and configure ESLint for React. Add custom ESLint rules. Integrate Prettier with ESLint to auto-format code. Set up VSCode to work seamlessly with both ESLint and Prettier.
🌐
Medium
medium.com › @frontend-newbie › integrating-prettier-with-eslint-for-your-create-react-app-in-vscode-153ebe89c1a2
Integrating Prettier with ESLint for your create-react-app in VSCode | by Frontend Newbie | Medium
September 5, 2021 - In a nutshell, we’ll use ESLint ... in ESLint using eslint-config-prettier. ... In VSCode, navigate to Extension tab, search for prettier and install Prettier extension....
🌐
DEV Community
dev.to › vikasparmar › prettier-configuration-for-reactnextjs-projects-2025-4oh5
Prettier Configuration for React/Next.js Projects | 2026 - DEV Community
1 week ago - { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true } Now your code will format automatically when you save! Before Prettier: const user={name:"John", age:30, email:"john@example.com" } After Prettier: const user = { name: 'John', age: 30, email: 'john@example.com', }; "Will this break my code?"