Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prettier extension in VS Code won't format JSX code

I'm trying to enable the Prettier extension to format JSX code when document is saved in VS Code, but after installing the extension does not work for me. I've tried to fix using the ways listed below:

  • Restarting VS Code (force quitting)
  • Reinstalling Prettier extension
  • Toggling the extension on and off inside settings
  • Enabling "format on save" in the Prettier settings
  • Toggling "React Snippets Experimental" in prettier settings
like image 325
Josh Avatar asked Jun 11 '26 21:06

Josh


2 Answers

Press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type 'format document' and then select Format Document option.

Then you will be asked to select the default formatter Select prettier formatter from the options list You're done

like image 55
Simranjeet Singh Avatar answered Jun 15 '26 06:06

Simranjeet Singh


Enable Prettier as default formatter in VS Code settings:

Settings > Default formatter > Prettier

like image 27
Josh Avatar answered Jun 15 '26 07:06

Josh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!