This is the documentation for version 1.4. Please consider upgrading your code to the latest stable version

Table Extension

(Note: this extension is included by default within the GFM extension)

The TableExtension adds the ability to create tables in CommonMark documents.


This extension is bundled with league/commonmark. This library can be installed via Composer:

composer require league/commonmark

See the installation section for more details.


Configure your Environment as usual and simply add the TableExtension provided by this package:

use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Extension\Table\TableExtension;

// Obtain a pre-configured Environment with all the CommonMark parsers/renderers ready-to-go
$environment = Environment::createCommonMarkEnvironment();

// Add this extension
$environment->addExtension(new TableExtension());

// Instantiate the converter engine and start converting some Markdown!
$converter = new CommonMarkConverter($config, $environment);
echo $converter->convertToHtml('Some Markdown with a table in it');


This package is fully compatible with GFM-style tables:



th | th(center) | th(right)
td | td         | td


<th style="text-align: left">th</th>
<th style="text-align: center">th(center)</th>
<th style="text-align: right">th(right)/th>
<td style="text-align: left">td</td>
<td style="text-align: center">td</td>
<td style="text-align: right">td</td>


| header 1 | header 2 | header 2 |
| :------- | :------: | -------: |
| cell 1.1 | cell 1.2 | cell 1.3 |
| cell 2.1 | cell 2.2 | cell 2.3 |


The Table functionality was originally built by Martin HasoĊˆ and Webuni s.r.o. before it was merged into the core parser.