Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!
THT Hypertext Toolkit
THT is a language that keeps the
good parts of PHP and fixes the rest.
THT fixes many aspects of PHP (diagram)

A Quick Look 

// Familiar variable and List syntax.
$colors = ['red', 'blue', 'green'];

// New JSON-style syntax for Maps
$colorHex = {
    red:   '#FF0000',
    green: '#00FF00',
    blue:  '#0000FF',

// Built-in types have methods using
// the mainstream 'dot' syntax.

// Extra parens aren't needed.
if $colors.length() > 3 {

// The standard library is organized
// into modules.
    title: 'Colors',
    body: bodyHtml($colors),

// Template Functions let you organize
// your output (views) however you like.
// (e.g. by component, module, file, etc.)
template bodyHtml($colors) {

    -- foreach $colors as $c {
        <li>{{ $c.toUpperCaseFirst() }}</>
    -- }

Read More:  Syntax Cheat Sheet  |  Full Language Tour

The Good Parts of PHP

Despite its flaws, PHP has a few unique strengths that has made it one of the most popular languages in the world.

THT keeps the good parts of PHP:

Easy Setup
PHP is available on every major web host and OS. Using it with Apache is fast out of the box, with virtually no system administration.
Simple Routes
In PHP, every file has a URL. THT automatically provides clean URLs (e.g. "/myBlog.tht" becomes "/my-blog"), and blocks access to private code.
Atomic Requests
State and data are automatically cleaned up after every request. This "share nothing" approach enables horizontal scaling and simplifies your app flow.
Web Focused
PHP is a web language at its core. THT embraces this even further by building in web security and framework features.
Batteries Included
PHP comes with a massive library of convenient functions. THT completely re-organizes this library and makes it more consistent.

Key THT Features

Organized Library.
PHP's massive library (5,000+ functions) is curated and organized into modules & classes.

Lists & Maps.
PHP arrays are split into clear List and Map types.

Module System.
File inclusion is supported via modules with built-in autoloading. No verbose namespaces.

Concise Syntax.
Optional syntax shortcuts make common patterns more convenient. (e.g. ||= for default assignment.)

Cleaner Code.
A compile-time format checker helps you write code that is easier to read and maintain.

Unicode Support.
String functions work with UTF-8 by default.

Friendly Errors.
The error pages are easy to read and have full stack traces.

Read More:  How THT Compares to PHP

Web Framework Included 

THT includes many tools that are useful for modern web development:

Built-In Security 

By default, THT defends against the most common security risks.

These safeguards are integrated into the language, providing better protection than if they were imported from a third-party library.


TypeStrings are used to prevent injection attacks, which are considered the #1 security vulnerability on the internet.

They can not be mixed with (unsafe) regular strings. Dynamic values are inserted via placeholders.

$q = sql'select name from users where id = {}';


$c = cmd'chmod {perms} {file}';
$c.fill('755', 'my_file.conf');

Other Safeguards

Read More:  All Security Enhancements


Out of the box, PHP is more than fast enough for most apps.

PHP 7 already offers major speed gains, but you can benefit even more by using an opcode cache like APC.

On a MacBook Pro, the core THT test suite (800 tests) finishes in 13 milliseconds.

THT is a safe choice, compared to the performance of other PHP libraries.

In a basic “Hello World” benchmark, THT is 6x faster than Laravel (1000 req/s vs 160 req/s) and uses 60% less memory (0.8 MB vs 2 MB).

The THT bundle is about 80x smaller than Laravel and its dependencies (180 KB vs 16 MB, zipped).

It also has built-in performance tools:

How It Works 

Once you set up a THT app, your workflow is the same as with PHP. After you edit a file, just save and refresh.

There are no build steps, background tasks, or server restarts to disrupt your flow.

When you add or update a .tht file, it is automatically transpiled to PHP on the first request. Then it is cached for performance.

The transpiled code is compatible with PHP 7.1+.

The transpiler itself is written in 100% PHP with no dependencies.

Third-party PHP libraries can be accessed through the PHP Interface.

Give It a Try 

THT is still in Beta, but if you’d like to try it out, it’s already suitable for most small-to-medium web apps.