Navigation Menu

Skip to content


Repository files navigation

NPM version Git Commit Git Releases CircleCI

This is JavaScript implementation of BBCode 2.0.

What's BB Code 2.0 (aka KBB)

BBCode is a lightweight markup language, introduced in 1998. It is base markup for phpBB forum system and vBulletin. Read more about BBCode on wikipedia

BBCode 2.0 is a new modern redefinition of BBCode. It introduces smart closing of tags, relaxes tags structure, introduces number of extensions and simplifies adding custom extensions.

It is alternative to other markup languages:

  • it's more structural, extendable and verbose than markdown
  • less structural and verbose than HTML

Therefore, the main use is for professional users: it's markup language and rich-text content description for server and browser, which can be rendered to HTML and SVG, as tags/text or directly into DOM.


Auto close

Instead of this

This is <b><i><u>complicated</u></i></b> - because you have to remember to close everything.

Why not just

This is [b][i][u]less complicated[/][/][/] - because you just auto-close last tag.

Smart to-HTML destructuring

Instead of this

This is <b>bold and <i>italic</i></b><i>or just italic</i> text.

Why not just

This is [b]bold and [i]italic[/b]or just italic[/i] text.


Instead of this

  <li>HTML way</li>
  <li>of handling</li>

Why not just

[li]BBCode way
[li]of handling

more examples...

More examples in /examples folder and at full BB2 documentation

BBCode-2 on node.js


npm install bb2

Run tests

npm test


// example_basic.js
const BBCodeHtml = require('bb2').BBCodeHtml
const bb         = new BBCodeHtml()
console.log(bb.parse('visible [0]invisible[1] [b]bold[/] [i]italic[/] [u]underline[/]'))


Look into /examples folder. To run examples, run this ONCE:

cd examples
node 0_prepare.js


  • prepares the folder structure as to pretend that's a real project.
  • creates the gallery.html file, which contains all the results from - just open that in the browser

After prepare, you can hit any of example_*.js like that:

node example_basic.js

For details go to

Other implementations

This is implementation of bb2 in JavaScript for node.js and browsers use. We also implemented bb2 in PHP for our older projects, but we never had time to publish it - contact us if you're interested.


  • remove Coffeescript dependency - full rewrite to ES6 completed
  • more functional approach - current one is OOP classes with inheritance. We will rewrite it to functional approach, to allow easier composition, like adding specific bb-tags without need of class-extend
  • separate parsing from rendering - currently parsing code and rendering code are closely coupled. We'll separate them to 2 functional blocks: parsing (to AST) and rendering (from AST)
  • move rendering from text based to Nate based - instead of building big HTML-strings, we'll use Nate to allow Universal building: direct DOM in the browser, HTML on server-side, LaTeX when needed, even SVG if possible
  • smart-table tags - smart creation of tables


  • Roman Pietrzak aka yosh - Architecture, Code, Tests, Documentation
  • Sylwester Wysocki aka dzik - Code, Tests, Examples

This project is sponsored by Kemu Studio and used as main rich-text engine in Calculla.