jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands


ASCII Art that represent text jQuery Terminal - JavaScript Library for Web Based Terminal Emulators

JavaScript Library for Web Based Terminal Emulators

npm bower Build and test Coverage Status downloads Paid Support LICENSE MIT


jQuery Terminal Emulator is a plugin for creating command line interpreters in your applications. It can automatically call JSON-RPC service when a user types commands or you can provide your own function in which you can parse user commands. It's ideal if you want to provide additional functionality for power users. It can also be used to debug your application.

You can use this JavaScript library to create a web based terminal on any website.

Because with this library you need to code all the commands yourself, you can call it fake terminal emulator. In contrast to library that will give you access to real terminal like online SSH. To have real online SSH I suggest to use xterm.js library.


  • You can create an interpreter for your JSON-RPC service with one line of code (just use url as first argument).

  • Support for authentication (you can provide functions when users enter login and password or if you use JSON-RPC it can automatically call login function on the server and pass token to all functions).

  • Stack of interpreters - you can create commands that trigger additional interpreters (eg. you can use couple of JSON-RPC service and run them when user type command)

  • Command Tree - you can use nested objects. Each command will invoke a function (own REPL), if the value is an object it will create a new interpreter and use the function from that object as commands. You can use as many nested object/commands as you like. If the value is a string it will create JSON-RPC service.

  • Support for command line history, it uses Local Storage if possible.

  • Support for tab completion.

  • Includes keyboard shortcut from bash like CTRL+A, CTRL+D, CTRL+E etc.

  • Bash reverse history search (CTRL+R / CTRL+G).

  • You can create and overwrite existing keyboard shortcuts.

  • Multiple terminals on one page (every terminal can have different commands, its own authentication function and its own command history).

  • It catches all exceptions and displays error messages in the terminal (you can see errors in your javascript and php code in terminal if they are in the interpreter function).

  • Using extended commands you can change working of the terminal without touching the front-end code (using echo method and terminal formatting like syntax). Read more in docs.

  • Easy way to change the style of the terminal (like color or cursor animation).

  • Chinese and Japanese character support.

  • You can use ASCII forms and collect information from users.

  • Animation (including typing effect and Canvas canvas adapter).

  • Support ANSI escapes codes.

  • Experimental mobile support, see open issues


You can test current version at this URL:

or if it doesn't use latest version (because of jsDelivr cache) you can force it with this URL:

And development version using:

You can use any version you want, everything what jsDelivr GH API accepts.


Include jQuery library, you can use cdn from https://jquery.com/download/

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>

Then include js/jquery.terminal-2.34.0.min.js and css/jquery.terminal-2.34.0.min.css

You can grab the files from CDN:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.34.0/js/jquery.terminal.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/2.34.0/css/jquery.terminal.min.css" rel="stylesheet"/>


<script src="https://cdn.jsdelivr.net/npm/[email protected]/js/jquery.terminal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/jquery.terminal.min.css">

If you always want latest version, you can get it from unpkg without specifying version, it will redirect to the latest ones:

<script src="https://unpkg.com/jquery.terminal/js/jquery.terminal.min.js"></script>
<link href="https://unpkg.com/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>

Bleeding Edge Version

If you want to test bleeding edge, development version of jQuery Terminal. You can use those files:

<script src="https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal@devel/js/jquery.terminal.min.js"></script>
<link href="https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal@devel/css/jquery.terminal.min.css" rel="stylesheet"/>

but it's not refreshed as fast as rawgit was, because it's CDN and need to be propagated to different servers.

Keyboard key polyfill

NOTE: From version 1.0.0 if you want to support old browsers then you'll need to use key event property polyfill. You can check the support for it on can I use.

<script src="https://unpkg.com/[email protected]/keyboard.js"></script>

Command Line

You can also install jQuery Terminal using command line, from bower repository:

bower install jquery.terminal

or npm registry:

npm install jquery.terminal

Example of usage

This is code that uses low level function, that gives you full control of the commands, just pass anything that the user types into a function.

jQuery(function($, undefined) {
    $('#term_demo').terminal(function(command) {
        if (command !== '') {
            var result = window.eval(command);
            if (result != undefined) {
    }, {
        greetings: 'Javascript Interpreter',
        name: 'js_demo',
        height: 200,
        width: 450,
        prompt: 'js> '

Here is a higher level call, using an object as an interpreter, By default the terminal will parse commands that a user types and replace number like strings with real numbers regex with regexes and process escape characters in double quoted strings.

jQuery(function($, undefined) {
        add: function(a, b) {
            this.echo(a + b);
        re: function(re, str) {
           if (re instanceof RegExp && re.test(str)) {
              this.echo(str + ' [[;green;]match]');
        foo: 'foo.php',
        bar: {
            sub: function(a, b) {
                this.echo(a - b);
    }, {
        height: 200,
        width: 450,
        prompt: 'demo> '

command add 2 2 will display 4 (not 22).

Command foo will change prompt to foo> and each new command will execute json-rpc method from foo.php script.

command bar will change the prompt to bar> and if you type sub 10 2 it will display 8. To exit from bar nested command you can type exit or press CTRL+D.

command re /^foo/ foo-bar will echo: "foo-bar match" where "match" will be green.

By default arguments are required but you can disable the check like this:

jQuery(function($, undefined) {
        add: function(...args) {
            this.echo(args.reduce((a,b) => a + b));
    }, {
       checkArity: false

And add command will accept any number of argments and it will sum them up (if they are numbers).

You can create JSON-RPC interpreter with authentication in just one line:

$('#term_demo').terminal('service.php', {login: true});

The rest of the code can be on the server, so you can write fully working application, without any front-end, that can be tested in browser.

First argument to terminal can also be array with objects strings and functions, with one requirement, that only one function can be used as last fallback for commands that was not found in RPC or in objects.

jQuery(function($, undefined) {
        add: function(...args) {
            this.echo(args.reduce((a,b) => a + b));
    } 'foo.php', function(command) {
       this.echo("You've typed " + command, {formatters: false, exec: false});
    }], {
       checkArity: false

More examples here. You can also check Full Documentation or Getting Started Guide on Wiki.

Quick Start Tutorials

If you want to start with jQuery Terminal you can look at those tutorials:


Because of security in version 1.20.0 links with protocols different than ftp or http(s) (it was possible to enter javascript protocol, that could lead to XSS if author of the app echo user input and save it in DB) was turn off by default. To enable it, you need to use anyLinks: true option.

In version 1.21.0 executing terminal methods using extendend commands [[ terminal::clear() ]] was also disabled by default because attacker (depending on your application) could execute terminal::echo with raw option to enter any html and execute any javascript. To enable this feature from this version you need to use invokeMethods: true option.

The features are safe to enable, if you don't save user input in DB and don't echo it back to different users (like with chat application). It's also safe if you escape formatting before you echo stuff.

If you don't save user input in DB but allow to echo back what user types and have enabled execHash options, you may have reflected XSS vulnerability if you enable this features. If you escape formatting this options are also safe.

NOTE: To disable exec if you have execHash (or echo stuff from users with invokeMethods: true), you can also set option {exec: false} to your echo call and use it only when you get values from server (not from DB indireclty from users). If you do this you will be able to echo stuff from users and execute terminal methods from server (this feature is mostly done just for that).


If you want to contribute read CONTRIBUTING.md first. Here are project contributors:

Jakub T. Jankiewicz


Hood Chatham


Zuo Qy


Marcel Link


Sébastien Warin


Christopher John Ryan




Snyk bot


Florian Schäfer


David Refoua


Ishan Ratnapala


Tomasz Ducin




Abdelrahman Omran


Anton Vasil'ev






Hraban Luyat


Jarry Shaw


Jon Steinich


Martin v. Löwis


Mateusz Paprocki






Robert W


Steve Phillips


Yutong Luo








Steve Kirkegard




jQuery Terminal Website contributors:

Jakub T. Jankiewicz


Marc Laporte


Rich Morin






Logan Rosen



Projects include with the source code:

Other code used inside the project or inspired by:

Personal thanks:

Also thanks to:


for cross-device testing opportunity.

Paid Support

You can request paid support, you can find details at support.jcubic.pl.


Licensed under MIT license

Copyright (c) 2011-2022 Jakub T. Jankiewicz

  • You can't type characters on android

    You can't type characters on android

    When you enter a site with fullscreen terminal on android the keyboard is popup but you can't enter characters

    Fixing this bug will probably fix issue on iPhone and iPad.

    opened by jcubic 69
  • Copy/Paste to terminal dosen't work in MacOSX

    Copy/Paste to terminal dosen't work in MacOSX

    Have Tested in Chrome, Safari, FF3

    MacOSX uses the apple/option meta keys + c / v for copy paste the jQuery terminal code is not acknowledging these key combos

    High Need testing help wanted 
    opened by kevzettler 60
  • Implement cursor movement in unix_formatting

    Implement cursor movement in unix_formatting

    I have idea for a new feature for jQuery Terminal

    I've already stared in unix_formatting.js#L517 but the parser have issues. This one is first version of the code, since then it was updated. Was not able to fix it myself and I've asked on StackOveflow: How to parse cursor ANSI escape codes?

    • [x] Add basic cursor movement
    • [x] Working SIXEL example
    • [x] Add H escape code
    feature resolved 
    opened by jcubic 43
  • Unix formatting for terminal echo

    Unix formatting for terminal echo

    Is it possible to simulate Unix echo formatting for backspaces and escape characters for terminal echo.

    Example: - [Start]]  --- Done] show be displayed as [Done]

    Bug resolved 
    opened by divyareddy12 43
  • Backend support (in flush) for newline : false

    Backend support (in flush) for newline : false

    The current behavior of term.echo(str, {newline : false}) is pretty buggy. For example: term.error(str, {newline : false}) doesn't produce red text, it interferes with term.get_prompt which will show the partially echoed line of text and term.set_prompt which won't work correctly at all, it seems to be incompatible with a bunch of the other options (I don't expect finalize to work). The ENTER handler it provides also causes weird effect.

    The problem is that the text echoed with newline : false is handled in a hacked-on extension. In order to get the behavior to be consistent and to make newline : false interact correctly with other formatting, the feature should be implemented in the core rendering engine and not as an add-on.

    This PR moves the implementation of the newline option into the main rendering engine. The main idea is to output the partial line as normal but whenever the output ends in a partial line of text, update the style for the command line to move it up and the first line of it over to position the input field to the right of the final partial output field.

    opened by hoodmane 29
  • Using prism with react and npm

    Using prism with react and npm

    I have question related to jQuery Terminal

    Hi, so I am looking into using jquery terminal on a nextjs react application. I have installed jquery and jquery.terminal via npm, all works great and I have rendered the terminal in a component using the library via import statements. However when wanting to add code highlighting support, I added Prism via npm but the following global function -> https://unpkg.com/jquery.terminal/js/prism.js currently fails.

    it is not available via npm, and when simply included via next/head as a regular