Fast Syntax HighLighter for PHP 5.3+

Download FSHL


FSHL is a free, open source, universal, fast syntax highlighter written in PHP. A very fast parser performs syntax highlighting for few languages and produces a HTML output.

FSHL library is a simple, easy to use syntax highlighter. Its API provides only one method that is really need to highlight sources and three auxiliary methods to sets lexer and output mode.

FSHL core is very flexible and it is very easy to add new languages. Feel free to do so and do not forget to share them with the rest of the world.


FSHL should be installed using the PEAR Installer. This installer is the backbone of PEAR, which provides a distribution system for PHP packages, and is shipped with every release of PHP since version 4.3.0.

The PEAR channel that is used to distribute FSHL needs to be registered with the local PEAR environment.

pear channel-discover pear.kukulich.cz

This has to be done only once. Now the PEAR Installer can be used to install packages from the kukulich channel:

pear install kukulich/FSHL

After the installation you can find the FSHL source files inside your local PEAR directory.


$highlighter = new \FSHL\Highlighter(new \FSHL\Output\Html());
$highlighter->setLexer(new \FSHL\Lexer\Php());
echo '<pre>';
echo $highlighter->highlight('<?php echo "Hello world!"; ?>');
echo '</pre>';


$highlighter = new \FSHL\Highlighter(new \FSHL\Output\Html(), \FSHL\Highlighter::OPTION_TAB_INDENT | \FSHL\Highlighter::OPTION_LINE_COUNTER);
echo '<pre>';
echo $highlighter->highlight('<?php echo "Hello world!"; ?>', new \FSHL\Lexer\Php());
echo '</pre>';


A nice default stylesheet is located in the style.css file.


FSHL requires PHP 5.3 or later.


This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


FSHL is distributed for free and you can use it however you want, as long as you follow its very simple license.

If you really like it and want to support its developers or if you want to support a particular feature to be implemented, you can send a small donation using your credit/debit card by clicking on the button bellow. The actual amount is fully up to you.

Thank you.