Site | NPM Module | GitHub Repo
simply-beautiful will beautify (pretty print) any web language including HTML, CSS, Javascript, and even JSON! Configure your own indent size and more!
Yes, this module works in both Node and browser environments, including compatability with Webpack and Browserify!
- HTML
- CSS
- Javascript
- JSON
Install with npm if you plan to use Simply Beautiful in a Node project or in the browser.
npm install simply-beautiful
If you plan to use simply-beautiful
in a browser environment, you will probably need to use Webpack, Browserify, or a similar service to compile it.
const beautify = require('simply-beautiful');
Install with CDN if you plan to use Simply Beautiful only in a browser environment.
<script src="https://cdn.jsdelivr.net/npm/simply-beautiful@latest"></script>
<script type="text/javascript">
var beautify = SimplyBeautiful(); // The script above exposes the global variable 'SimplyBeautiful'
</script>
After you have followed the install step, you can start using simply-beautiful
with your website or software!
var options = {
indent_size: 2,
// ...
}
console.log(beautify.html('<div><div><div></div></div></div>', options));
console.log(beautify.css('p { color: red; text-align: center; }', options));
console.log(beautify.js("function test() { (function() { console.log('Hello World!') }()); }", options));
console.log(beautify.json('{ "top": { "middle": { "bottom": 69 } } }', options));
Find a kitchen-sink example of the options you can supply to customize the output of the beautifier!
var options = {
indent_size: 4,
space_before_conditional: true,
jslint_happy: true,
max_char: 0,
}
Simply beautify will pretty print any HTML, CSS Javascript, or JSON and it works in both browser and Node.js environments! Based on this pen here.
If you are still having difficulty, we would love for you to post a question to the Simply Beautiful issues page. It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!)
Somiibo: A Social Media Bot with an open-source module library.
JekyllUp: A website devoted to sharing the best Jekyll themes.
Slapform: A backend processor for your HTML forms on static sites.
SoundGrail Music App: A resource for producers, musicians, and DJs.
Hammock Report: An API for exploring and listing backyard products.
Ask us to have your project listed! :)