User Rating 0.0
Total Usage 0 times
Category CSS Tools
Bootstrap 2 Input
Is this tool helpful?

Your feedback helps us improve.

About

Migrating from Bootstrap 2 to Bootstrap 3 involves hundreds of breaking changes across CSS class names, LESS/Sass variables, grid systems, and HTML structure. The grid alone shifted from span* to col-md-*, row-fluid became simply row, and the responsive utilities were entirely renamed. Missing a single class rename in a large codebase causes silent layout failures that are difficult to trace. This tool performs a multi-pass conversion covering class renames, variable migration (camelCase to dashed-base), icon class translation (icon-*glyphicon glyphicon-*), and structural HTML changes. It processes CSS, HTML, LESS, Sass, and template files. The converter handles approximately 180 class mappings and 120 variable mappings extracted from the official Bootstrap 3 migration guide. Note: dynamically constructed class strings in JavaScript or server-side templates cannot be statically analyzed. The tool flags ambiguous matches for manual review rather than silently producing incorrect output.

bootstrap css converter bootstrap migration bootstrap 2 to 3 css class converter bootstrap upgrade frontend migration

Formulas

The converter operates as a multi-pass text transformation pipeline. Each pass applies a category of regular expression substitutions.

Output = P4 P3 P2 P1(Input)

Where P1 = Variable conversion pass, P2 = CSS class rename pass, P3 = HTML structural pass, P4 = Grid system pass.

Class replacement uses boundary-aware matching to avoid partial substitutions. For a class mapping old new, the regex pattern is constructed as:

regex = (?<=["'\s])old(?=["'\s])

This ensures span6 inside a class attribute is matched but colspan6 is not. The diff algorithm compares input and output arrays line by line, marking lines as ADDED, REMOVED, or UNCHANGED, and produces a unified diff view with context lines.

Reference Data

Bootstrap 2 ClassBootstrap 3 EquivalentCategory
row-fluidrowGrid
span1 - span12col-md-1 - col-md-12Grid
container-fluidcontainer-fluid (unchanged)Grid
brandnavbar-brandNavbar
nav-collapsenavbar-collapseNavbar
nav-togglenavbar-toggleNavbar
btn-navbarnavbar-btnNavbar
hero-unitjumbotronComponents
icon-*glyphicon glyphicon-*Icons
btn (alone)btn btn-defaultButtons
btn-minibtn-xsButtons
btn-smallbtn-smButtons
btn-largebtn-lgButtons
alert-erroralert-dangerAlerts
control-groupform-groupForms
controls(removed, use form-group)Forms
input-block-levelform-controlForms
input-miniinput-xs (custom)Forms
input-smallinput-smForms
input-largeinput-lgForms
input-xlargeinput-lgForms
input-xxlargeinput-lgForms
input-prependinput-groupForms
input-appendinput-groupForms
add-oninput-group-addonForms
thumbnailimg-thumbnailImages
unstyledlist-unstyledTypography
inline (on ul)list-inlineTypography
mutedtext-mutedTypography
label (component)label label-defaultLabels
label-importantlabel-dangerLabels
bar (progress)progress-barProgress
bar-dangerprogress-bar-dangerProgress
bar-warningprogress-bar-warningProgress
bar-successprogress-bar-successProgress
bar-infoprogress-bar-infoProgress
accordionpanel-groupPanels
accordion-grouppanel panel-defaultPanels
accordion-headingpanel-headingPanels
accordion-bodypanel-collapsePanels
accordion-innerpanel-bodyPanels
visible-phonevisible-xsResponsive
visible-tabletvisible-smResponsive
visible-desktopvisible-md visible-lgResponsive
hidden-phonehidden-xsResponsive
hidden-tablethidden-smResponsive
hidden-desktophidden-md hidden-lgResponsive
.img-polaroid.img-thumbnailImages

Frequently Asked Questions

The converter uses context-aware matching. Classes like bar are only replaced when found within a .progress context or adjacent to other Bootstrap progress classes. Standalone occurrences of bar in CSS selectors or HTML are flagged in the summary as "Ambiguous - manual review recommended" rather than auto-replaced. The same logic applies to brand, label, and other common English words used as Bootstrap 2 class names.
Yes. The variable pass detects both @variable (LESS) and $variable (Sass/SCSS) prefixes. It converts camelCase variable names to dashed-base equivalents (e.g., @baseFontSize becomes @font-size-base). Variables removed in Bootstrap 3 are commented out with a note indicating the removal. Approximately 120 variable mappings are included from the official migration documentation.
In HTML class attributes, icon-search is replaced with glyphicon glyphicon-search and the <i> tag is changed to <span>. However, in JavaScript strings like $('.icon-search'), the converter flags the line but does not auto-replace, because the CSS selector syntax differs from class attribute syntax. The summary report lists all such occurrences with line numbers for manual correction.
The converter preserves template expressions (<%= %>, {{ }}, <% %>) by temporarily replacing them with unique placeholder tokens before processing. After all passes complete, tokens are restored to their original template expressions. This prevents the regex engine from matching partial class names inside dynamic expressions. However, dynamically constructed class strings inside template logic blocks cannot be statically analyzed and are skipped.
By default, span* classes map to col-md-* as the closest semantic equivalent to Bootstrap 2's default grid. The tool provides a dropdown option to select the target breakpoint prefix (col-xs-, col-sm-, col-md-, or col-lg-). Additionally, offset* becomes col-md-offset-* using the same selected prefix. The row-fluid class always becomes row regardless of the selected prefix, since Bootstrap 3 uses a single fluid grid system.
The converter processes files up to approximately 500 KB in under 200 ms on modern hardware. Files between 500 KB and 2 MB trigger a progress indicator. The processing is synchronous on the main thread since Web Workers cannot access the DOM mappings efficiently for this workload size. For very large codebases, process files individually rather than concatenating them.