Prettier custom rules (formatter)?

Is there a way to set a full custom rule for prettier code formatter?

For example, if you don’t like this CSS coding style:

Body { color: red; }

But you like it that way:

Body { color:red; }

No space after : and a new line for { and }

Or in HTML prettier removes new lines after opening a DIV like:

<div> <p>My paragraph Text</p> <p>My paragraph Text</p> </div>

But I would not remove my custom new lines like:


<p>My paragraph Text</p>

<p>My paragraph Text</p>


Prettier makes the Code like this:

<div> <p>My paragraph Text</p>

<p>My paragraph Text</p> </div>

In between, prettier “allows” new lines. But inside something like a DIV, the first and last element “touch” the opening and ending DIV. So basically for HTML I would like to disable the deletion of new blank lines.

Is there a way to create a “coding style template” for each language so that prettier follow that “rules”?!

Or is there an other extension to do that?

Every company have their own “coding style”. 90% is the same, but some small things are different.

For example 4 new blank lines, after each Function to separate them better from each other. But if those lines get removed, you can’t use prettier…

So basically I (we) search for a full customization Coding style (formatter) Extension for VSCode.

Thanks for reading, and sry for the long text.

Best wishes, and stay healthy. Benjamin Schäfer

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

You can customize your prettier configurations by adding a .prettierrc file in your project root directory.

Read more here about config for languages -