Get started with js-beautify CDN

MIT licensed

Js-beautify: popular JS, JSON formatter for code readability.

Tags:
  • beautify
  • beautifier
  • formatter
  • code-quality

Stable version

Copied!

How to start using js-beautify CDN


<!DOCTYPE html>
<html>
<head>
    <title>Get started with js-beautify CDN - cdnhub.io</title>
    <script src="https://cdn.cdnhub.io/js-beautify/1.15.1/beautify.min.js"></script>
</head>
<body>
    <button id="formatCode">Format Code</button>
    <script>
        document.getElementById('formatCode').addEventListener('click', () => {
            const code = `
function add(x, y) {
    return x + y;
}

function multiply(x, y) {
    return x * y;
}

const result = add(multiply(2, 3), 5);
console.log(result);
            `;

            const formattedCode = beautify(code, { format: 'jsx' });
            console.log('Original Code:');
            console.log(code);
            console.log('Formatted Code:');
            console.log(formattedCode);
            document.body.innerHTML += `<pre>${formattedCode}</pre>`;
        });
    </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions