BBCode to HTML Converter
Convert forum BBCode to raw HTML instantly. Features a real-time preview, XSS sanitization, and support for nested tags, lists, and code blocks.
About
Legacy forums and bulletin boards often rely on Bulletin Board Code (BBCode), a lightweight markup language designed to be safer than raw HTML. However, migrating content to modern Content Management Systems (CMS) or preserving archived threads often requires converting this markup into standard semantic HTML5.
This tool performs a rigorous transformation process. It does not simply replace strings; it employs a Guard Pattern algorithm. First, it isolates [code] and [noparse] blocks to prevent corruption of technical data. Then, it iterates through formatting tags (like b, i, url) using non-greedy Regular Expressions. Finally, it sanitizes the output to ensure the generated HTML is safe for rendering.
Note: While this converter handles standard nesting, malformed BBCode (e.g., overlapping tags like [b][i]...[/b][/i]) depends on the browser's HTML correction engine for the final preview rendering.
Formulas
The transformation logic follows a sequential substitution model, defined as:
HTML(x) = Sanitize(Restore(Parse(Guard(x))))
Where the Guard function protects code blocks:
And the Parse function applies regex mappings, e.g., for bold text:
s/[b](.*?)[/b]/<strong>$1</strong>/g
Legend:
- x = Input String (Raw BBCode)
- Guard = Extraction of immutable blocks
- Parse = Recursive application of regex rules
- Restore = Re-insertion of guarded blocks
Reference Data
| BBCode Tag | HTML Equivalent | Description |
|---|---|---|
[b]Text[/b] | <strong>Text</strong> | Bold text emphasis |
[i]Text[/i] | <em>Text</em> | Italic text emphasis |
[u]Text[/u] | <span style="text-decoration:underline;">...</span> | Underlined text |
[s]Text[/s] | <del>Text</del> | Strikethrough text |
[url=https://x.com]Link[/url] | <a href="https://x.com">Link</a> | Hyperlinks |
[img]src.jpg[/img] | <img src="src.jpg" /> | Images |
[quote]Text[/quote] | <blockquote>Text</blockquote> | Block quotes |
[code]var x = 1;[/code] | <pre><code>var x = 1;</code></pre> | Code blocks (preserved) |
[list][*]Item[/list] | <ul><li>Item</li></ul> | Unordered Lists |
[size=20]Text[/size] | <span style="font-size:20px">...</span> | Font sizing |
[color=#FF0000]Text[/color] | <span style="color:#FF0000">...</span> | Text coloration |
Frequently Asked Questions
tags to preserve the visual structure of forum posts. Double line breaks are often interpreted as paragraph breaks depending on the context.