AST-based JavaScript Syntax Highlighter
Unlike regex-based highlighters, Squirrel Pie parses your code into an Abstract Syntax Tree for true semantic understanding.
Hover over any element to see its AST node type. Perfect for learning and debugging.
Just Acorn for parsing. No heavy frameworks or libraries needed.
Built with Shadow DOM for complete style encapsulation. Won't interfere with your styles.
Responds to attribute changes in real-time. Perfect for live editors.
Supports ES2022 syntax including classes, async/await, and more.
<script type="module">
import 'https://cdn.jsdelivr.net/npm/squirrel-pie@latest/index.js';
</script>
<squirrel-pie>
function hello(name) {
return `Hello, ${name}!`;
}
</squirrel-pie>
npm install squirrel-pie
import 'squirrel-pie';
Each theme teaches you AST node types through color! Hover over any code element to see its AST node type. The commented CSS files are perfect for learning how JavaScript is structured at the AST level.
Clean, minimalist light theme perfect for documentation
Easy on the eyes with the classic Solarized palette
Retro groove with warm, earthy tones
Download any theme CSS file, modify the colors, and use it with the theme attribute. Each CSS class corresponds to an AST node type - perfect for learning!
<squirrel-pie theme="./my-custom-theme.css">
your code here
</squirrel-pie>
For detailed documentation, API reference, and more examples, visit the GitHub repository.
<!-- Using slot content -->
<squirrel-pie>
const x = 42;
</squirrel-pie>
<!-- Using value attribute -->
<squirrel-pie value="const x = 42;"></squirrel-pie>
<!-- Dynamic updates -->
<script>
document.querySelector('squirrel-pie')
.setAttribute('value', 'const y = 100;');
</script>