VSCode Prettier format on save

If this serves no other person than my future self, so be it. I find I’m always forgetting simple set-ups that take a few steps and never re-visit until I’m installing settings on a new machine. To get Prettier to do all its magic upon saving a file, …


This content originally appeared on DEV Community and was authored by Sarkis Peha

If this serves no other person than my future self, so be it. I find I'm always forgetting simple set-ups that take a few steps and never re-visit until I'm installing settings on a new machine. To get Prettier to do all its magic upon saving a file, follow this cookbook:

1. Install Prettier extension in VSCode.
2. Cmd + shift + p and search Open User Settings (JSON)
Image description
3. Add the following to the settings.json

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

4. Add the file .prettierrc to the root of the project and add options as one sees fit.

{
    "tabWidth": 4
}


This content originally appeared on DEV Community and was authored by Sarkis Peha


Print Share Comment Cite Upload Translate Updates
APA

Sarkis Peha | Sciencx (2025-01-03T03:58:40+00:00) VSCode Prettier format on save. Retrieved from https://www.scien.cx/2025/01/03/vscode-prettier-format-on-save/

MLA
" » VSCode Prettier format on save." Sarkis Peha | Sciencx - Friday January 3, 2025, https://www.scien.cx/2025/01/03/vscode-prettier-format-on-save/
HARVARD
Sarkis Peha | Sciencx Friday January 3, 2025 » VSCode Prettier format on save., viewed ,<https://www.scien.cx/2025/01/03/vscode-prettier-format-on-save/>
VANCOUVER
Sarkis Peha | Sciencx - » VSCode Prettier format on save. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/03/vscode-prettier-format-on-save/
CHICAGO
" » VSCode Prettier format on save." Sarkis Peha | Sciencx - Accessed . https://www.scien.cx/2025/01/03/vscode-prettier-format-on-save/
IEEE
" » VSCode Prettier format on save." Sarkis Peha | Sciencx [Online]. Available: https://www.scien.cx/2025/01/03/vscode-prettier-format-on-save/. [Accessed: ]
rf:citation
» VSCode Prettier format on save | Sarkis Peha | Sciencx | https://www.scien.cx/2025/01/03/vscode-prettier-format-on-save/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.