A small TypeScript library that lets you evaluate code in a sandboxed environment everywhere with TryItOnline.
Supported languages
Before getting to the examples, please note that tio.js
supports a wide variety of programming languages. These programming languages contain their own IDs that can be used in customizing the programming language to use.
For example javascript-node
is for running JavaScript in a Node.js runtime, python3
is for running in a Python 3 environment, etc.
In code, these can be retrieved programmatically by using:
console.log(tio.languages)
Therefore, here are the full list of supported programming languages alongside with their IDs in alphabetical order for your convenience.
Practical programming languages (260)
Name | ID |
---|
ABC | abc |
ABC-assembler | abc-assembler |
Ada (GNAT) | ada-gnat |
Agda | agda |
ALGOL 68 (Genie) | algol68g |
Alice ML | aliceml |
APL (Dyalog Unicode) | apl-dyalog |
APL (Dyalog Classic) | apl-dyalog-classic |
APL (Dyalog Extended) | apl-dyalog-extended |
APL (dzaima/APL) | apl-dzaima |
APL (ngn/apl) | apl-ngn |
Appleseed | appleseed |
ASPeRiX | asperix |
Assembly (as, x64, Linux) | assembly-as |
Assembly (fasm, x64, Linux) | assembly-fasm |
Assembly (gcc, x64, Linux) | assembly-gcc |
Assembly (JWasm, x64, Linux) | assembly-jwasm |
Assembly (nasm, x64, Linux) | assembly-nasm |
ATS2 | ats2 |
Attache | attache |
AWK | awk |
Bash | bash |
bc | bc |
BeanShell | beanshell |
Boo | boo |
bosh | bosh |
Bracmat | bracmat |
Brat | brat |
C (clang) | c-clang |
C (gcc) | c-gcc |
C (tcc) | c-tcc |
Caboose | caboose |
CakeML | cakeml |
calc (TTK) | calc2 |
Ceylon | ceylon |
Charm | charm |
Chapel | chapel |
Checked C | checkedc |
Cheddar | cheddar |
CIL (Mono IL assembler) | cil-mono |
cixl | cixl |
Clean | clean |
CLIPS | clips |
Common Lisp | clisp |
Clojure | clojure |
COBOL (GNU) | cobol-gnu |
Cobra | cobra |
Coconut | coconut |
CoffeeScript 1 | coffeescript |
CoffeeScript 2 | coffeescript2 |
C++ (clang) | cpp-clang |
C++ (gcc) | cpp-gcc |
CPY | cpy |
Cryptol | cryptol |
Crystal | crystal |
C# (.NET Core) | cs-core |
C# (Visual C# Compiler) | cs-csc |
C# (Visual C# Interactive Compiler) | cs-csi |
C# (Mono C# compiler) | cs-mono |
C# (Mono C# Shell) | cs-mono-shell |
Curry (PAKCS) | curry-pakcs |
Curry (Sloth) | curry-sloth |
Cyclone | cyclone |
D | d |
Dafny | dafny |
Dart | dart |
Dash | dash |
dc | dc |
dg | dg |
DScript | dscript |
eC | ec |
ecpp + C (gcc) | ecpp-c |
ecpp + C++ (gcc) | ecpp-cpp |
Dyvil | dyvil |
ed | ed |
Egel | egel |
ELF (x86/x64, Linux) | elf |
Elixir | elixir |
Emacs Lisp | emacs-lisp |
Erlang (escript) | erlang-escript |
es | es |
Euphoria 3 | euphoria3 |
Euphoria 4 | euphoria4 |
Factor | factor |
Fantom | fantom |
Farnsworth | farnsworth |
Felix | felix |
fish | fish-shell |
FOCAL-69 | focal |
Forth (gforth) | forth-gforth |
Fortran (GFortran) | fortran-gfortran |
F# (.NET Core) | fs-core |
F# (Mono) | fs-mono |
Funky | funky |
Funky 2 | funky2 |
GAP | gap |
Gema | gema |
gnuplot | gnuplot |
Go | go |
Granule | granule |
Groovy | groovy |
Gwion | gwion |
HadesLang | hades |
Haskell | haskell |
Haskell 1.2 (Gofer) | haskell-gofer |
Haskell 98 (Hugs) | haskell-hugs |
Literate Haskell | haskell-literate |
Haxe | haxe |
Hobbes | hobbes |
Huginn | huginn |
Hy | hy |
Icon | icon |
Idris | idris |
ink | ink |
Io | io |
J | j |
jq | jq |
Jx | jx |
Java (JDK) | java-jdk |
Java (OpenJDK 8) | java-openjdk |
JavaScript (Babel Node) | javascript-babel-node |
JavaScript (Node.js) | javascript-node |
JavaScript (SpiderMonkey) | javascript-spidermonkey |
JavaScript (V8) | javascript-v8 |
Joy | joy |
Julia 0.4 | julia |
Julia 1.0 | julia1x |
Julia 0.5 | julia5 |
Julia 0.6 | julia6 |
Julia 0.7 | julia7 |
K (Kona) | k-kona |
K (ngn/k) | k-ngn |
K (oK) | k-ok |
Kobeři-C | koberi-c |
Koka | koka |
Kotlin | kotlin |
ksh | ksh |
Lean | lean |
Lily | lily |
LLVM IR | llvm |
Lua | lua |
Lua (LuaJIT) | lua-luajit |
Lua (OpenResty) | lua-openresty |
M4 | m4 |
Make | make |
Mamba | mamba |
Wolfram Language (Mathematica) | mathematica |
Mathics | mathics |
Maxima | maxima |
Moonscript | moonscript |
Mouse-79 | mouse |
Mouse-2002 | mouse2002 |
Mouse-83 | mouse83 |
MUMPS | mumps |
MY-BASIC | my-basic |
Nial | nial |
Nim | nim |
Oberon-07 | oberon-07 |
Object Pascal (FPC) | object-pascal-fpc |
Objective-C (clang) | objective-c-clang |
Objective-C (gcc) | objective-c-gcc |
occam-pi | occam-pi |
OCaml | ocaml |
Octave | octave |
Odin | odin |
OSH | osh |
Pari/GP | pari-gp |
Pascal (FPC) | pascal-fpc |
Perl 4 | perl4 |
Perl 5 | perl5 |
Perl 5 (cperl) | perl5-cperl |
Perl 6 | perl6 |
Perl 6 (Niecza) | perl6-niecza |
Phoenix | phoenix |
PHP | php |
Physica | physica |
PicoLisp | picolisp |
Pike | pike |
PILOT (psPILOT) | pilot-pspilot |
PILOT (RPilot) | pilot-rpilot |
Pony | pony |
Positron | positron |
PostScript (xpost) | postscript-xpost |
PowerShell | powershell |
PowerShell Core | powershell-core |
Prolog (Ciao) | prolog-ciao |
Prolog (SWI) | prolog-swi |
Proton | proton |
Proton 2.0 | proton2 |
P# | ps-core |
Pure | pure |
PureScript | purescript |
Python 1 | python1 |
Python 2 | python2 |
Python 2 (Cython) | python2-cython |
Python 2 (IronPython) | python2-iron |
Python 2 (Jython) | python2-jython |
Python 2 (PyPy) | python2-pypy |
Python 3 | python3 |
Python 3.8 (pre-release) | python38pr |
Python 3 (Cython) | python3-cython |
Python 3 (PyPy) | python3-pypy |
Python 3 (Stackless) | python3-stackless |
Q# | qs-core |
R | r |
Racket | racket |
RAD | rad |
Rapira | rapira |
Reason | reason |
REBOL | rebol |
REBOL 3 | rebol3 |
Red | red |
Rexx (Regina) | rexx |
Ring | ring |
rk | rk |
Röda | roda |
Ruby | ruby |
Rust | rust |
Scala | scala |
Chez Scheme | scheme-chez |
CHICKEN Scheme | scheme-chicken |
Gambit Scheme (gsi) | scheme-gambit |
Guile | scheme-guile |
sed 4.2.2 | sed |
sed | sed-gnu |
sfk | sfk |
Shnap | shnap |
Sidef | sidef |
Simula (cim) | simula |
SISAL | sisal |
Standard ML (MLton) | sml-mlton |
SNOBOL4 (CSNOBOL4) | snobol4 |
Assembly (MIPS, SPIM) | spim |
SQLite | sqlite |
Squirrel | squirrel |
Stacked | stacked |
Swift | swift4 |
Tcl | tcl |
tcsh | tcsh |
TemplAt | templat |
TypeScript | typescript |
uBASIC | ubasic |
Ursala | ursala |
Vala | vala |
Visual Basic .NET (.NET Core) | vb-core |
Visual Basic .NET (Mono) | visual-basic-net-mono |
Visual Basic .NET (VBC) | visual-basic-net-vbc |
V (vlang.io) | vlang |
VSL | vsl |
WebAssembly (WaWrapper) | wasm |
Wren | wren |
Yabasic | yabasic |
yash | yash |
B (ybc) | ybc |
Z3 | z3 |
Zephyr | zephyr |
Zig | zig |
zkl | zkl |
Zoidberg | zoidberg |
Zsh | zsh |
Esoteric programming languages (421)
Examples
In your code:
import tio from 'tio.js'
Evaluating a code
const response = await tio('console.log("Hello, World!");')
console.log(response)
Evaluating a code from another programming language
let response = await tio('print("Hello, World!")', {
language: 'python3'
})
console.log(response)
tio.defaultLanguage = 'python3'
response = await tio('print("Hello, World!")')
console.log(response)
Surpressing infinite loops with timeouts
let response = await tio('for (;;);', {
timeout: 10000
})
console.log(response)
tio.defaultTimeout = 10000
response = await tio('for (;;);')
console.log(response)
Passing in extra compiler flags
const code = `
fn main() {
#[cfg(feature = "something")]
println!("this will be printed");
}
`
let response = await tio(code, {
language: 'rust',
cflags: ['--cfg', 'feature="something"']
})
console.log(response)
tio.defaultCflags = ['--cfg', 'feature="something"']
response = await tio(code, {
language: 'rust'
})
console.log(response)
Passing in command-line arguments
let response = await tio('console.log(process.argv.slice(2).join(", "))', {
argv: ['Hello', 'World!']
})
console.log(response)
tio.defaultArgv = ['Hello', 'World!']
response = await tio('console.log(process.argv.slice(2).join(", "))')
console.log(response)
Donations
If you want to support this project, consider donating! ❤