Redactor Redactor 1.x Creating Custom Formats

The page you’re currently looking at contains information related to Redactor 1.x. Please visit Custom Formatting for the relevant information for Redactor 2.x.

For Redactor 1.2.0, we added something special to do exactly what many of you requested, custom formatting. By making use of the Redactor Styles Plugin by JP DeVries, you can create custom formats to more easily format your text. Redactor TVs can even have their own custom formats that overrides the System Defaults.

Using className to style individiual format options in the toolbar

To add custom styles to Redactor you will need to set the redactor.stylesJson System Setting to properly formatted JSON that defines each of your styles.

To make sure your formats are valid JSON you can use the JSONLint Validator. For using with Custom Redactor TVs set the Custom Formatting field under Template Variable Input Options.

To style the options in the dropdown, you will need to create a CSS file and reference it with the Stylesheet option (called Iframe CSS prior to 1.2.3). E.g.: .redactor_toolbar .your_className_value { your: styling; }

Format Options


The unique name of the custom format. (Required)


A CSS classname to assign to the associated option in the toolbar. Use to style how the option appears.


A class to be applied to the selection. Will be wrapped in a span tag. Must be set if neither wrap or style is set.


Inline CSS to be applied to the selection. Must be set if neither spanClass or wrap is set.


HTML tag to wrap the selection in. Must be set if neither spanClass or style is set.


Set to 1,0, or -1 to control whether block or inline wrapping is applied. Defaults to 0.

  • 0 auto determines based on wrap tag
  • 1 forces block level wrapping
  • -1 prevents block level wrapping

Creating Custom Formats

Similar to the Clips Plugin, options for custom styles are set using JSON. Make sure that each format is a valid JSON Object, meaning it needs to be wrapped in curly braces. The properties and property values need to be wrapped in double quotes. Each format should be separated by a comma and everything should be wrapped in square brackets.


See some examples below for more information on how you can create custom formats and utilize the available propertie.

Styling Toolbar Options

Adding custom formats and styling their toolbar option using CSS.





{"btnName":"PHP Code",
"className":"redactor_format_pre redactor_dropdown_pre",
"spanClass":"brush: php"}]

Add this CSS to style the toolbar options.

.redactor_dropdown .redactor_format_note {
  color: #468847;
.redactor_dropdown .redactor_format_warning {
  color: #806637;
.redactor_dropdown .redactor_format_info {
  color: #3a87ad;
.redactor_dropdown .redactor_format_danger {
  color: #b94a48;

Superscript & Subscript

Create formats for formatting text using superscript and subscript tags.


Inline Formatting

Adds an option to the custom formats toolbar that wraps the selected text in a code tag.

[{"btnName":"Inline Code",

Block Formatting

Adds an option to the custom formats toolbar that wraps the entire block of selected text in a code tag.

[{"btnName":"Inline Code",

Block Level By Tag

This will add one option to the custom formats toolbar that wraps the selected text in a code tag and apply an ‘inline-code’ class. Since forceBlock is 0, whether or not to use block level wrapping is auto determined based on the wrapping tag.

[{"btnName":"Block Code",

Inline Style

Set inline CSS on selected text.


Multiple Options

Adds multiple options to the dropdown.


Bootstrap Examples

Some examples creating custom formats for the Bootstrap CSS Framework.

 "btnName":"Lead Text",
 "wrap":"p class='lead'"
 "btnName":"Small Text",
 "btnName":"Default Button",
 "wrap":"a class='btn btn-default'",
 "btnName":"Primary Button",
 "wrap":"a class='btn btn-primary'",
 "btnName":"Read More",
 "wrap":"a class='read-more'",
 "btnName":"Responsive Table",
 "wrap":"div class='table-responsive'",
 "btnName":"Label Default",
 "spanClass":"label label-default",
 "btnName":"Label Primary",
 "spanClass":"label label-primary",
 "btnName":"Alert Success",
 "wrap":"div class='alert alert-success'",
 "btnName":"Alert Info",
 "wrap":"div class='alert alert-info'",
 "wrap":"div class='well'",