htmlautoformatting

Format HTML from the command line


Is it possible to format HTML automatically with a tool, similar to how ESLint formats JavaScript?
Why does it seem that there aren't many customizable options that you can integrate as part of your development pipeline?

I would wish to format HTML in the following way automatically with a command run from the terminal:

<input
  class="input-style"
  placeholder="Replace me!"
/>

For example, I could npm run html-lint and it would fix the syntax in HTML files and warn about cases it can't fix.


Solution

  • maybe what you are looking for is prettier, this also supports CLI, even you can also make config, see the complete documentation here. Prettier CLI

    I hope this helps.