Menu
Learn
Overview Tutorial Snippets
Build
Editor Playground Compiler API
Docs
Language Spec u keyword Feature Status
Platform
Server Transpile Web & Templates

Compiler API

Compile U source to C, WebAssembly, or portable binaries over HTTP. No SDK, no account — just curl.

Base URL

https://compiler.ulanguage.org

Endpoints

endpointwhat it does
GET/healthService status, available targets, limits
POST/compileCompile U source → C, WASM, or binary
POST/runCompile + execute, return stdout
POST/uploadUpload a .zip of source files → transpile + compile

Quick start

Get C source

# Send U source, get C back as JSON
printf 'f main() -> I\n\tr => 42\n' | \
  curl -s -X POST -H 'Content-Type: text/plain' \
  'https://compiler.ulanguage.org/compile?format=c' \
  --data-binary @- | python3 -m json.tool

Get a portable binary

# Cosmopolitan APE — runs on macOS, Linux, Windows
printf 'f main() -> I\n\tr => 42\n' | \
  curl -s -X POST -H 'Content-Type: text/plain' \
  'https://compiler.ulanguage.org/compile?format=binary&target=portable' \
  --data-binary @- -o hello.com
chmod +x hello.com
./hello.com
# → 42

Get WebAssembly

printf 'f main() -> I\n\tr => 42\n' | \
  curl -s -X POST -H 'Content-Type: text/plain' \
  'https://compiler.ulanguage.org/compile?format=wasm' \
  --data-binary @- -o hello.wasm

Compile and run

# Server compiles, runs, returns stdout + exit code
curl -s -X POST -H 'Content-Type: application/json' \
  'https://compiler.ulanguage.org/run' \
  -d '{"source": "f main() -> I\n\tlog(\"hello\")\n\tr => 0"}' | python3 -m json.tool

# Response:
# {
#   "compiled": true,
#   "output": "hello\n",
#   "exit_code": 0
# }

Upload a project

Send a .zip containing .u, .php, .py, .js, or .ts files. Non-U files are transpiled to U automatically. All U files are concatenated in dependency order and compiled.

Transpile only (get U source back)

# Upload a zip of PHP files, get back the U translation
curl -s -X POST   'https://compiler.ulanguage.org/upload?action=transpile'   -F 'file=@myproject.zip' | python3 -m json.tool

# Response:
# {
#   "u_source": "// Transpiled from ...",
#   "files": ["main.u", "utils.u"],
#   "files_count": 2,
#   "transpiled_from": ["main.php", "utils.php"]
# }

Compile a project to a portable binary

# Upload zip → transpile → compile → download binary
curl -s -X POST   'https://compiler.ulanguage.org/upload?format=binary&target=portable'   -F 'file=@myproject.zip' -o myproject.com
chmod +x myproject.com
./myproject.com

Compile a multi-file U project

# Zip your .u files and compile them together
zip project.zip src/*.u
curl -s -X POST   'https://compiler.ulanguage.org/upload?format=c'   -F 'file=@project.zip' | python3 -c "
import sys, json; d = json.load(sys.stdin)
print(d['files_count'], 'files compiled')
open('output.c','w').write(d['c'])
"

Send a raw zip (no form field)

# You can also POST the zip bytes directly
curl -s -X POST -H 'Content-Type: application/zip'   'https://compiler.ulanguage.org/upload?format=c'   --data-binary @project.zip | python3 -m json.tool

Upload parameters

paramvaluesdefault
actioncompile · transpilecompile
formatc · binary · wasm · portablec
targetnative · portable · windowsnative

Supported file types in the zip: .u (compiled directly), .php .js .ts .py (transpiled to U first). Maximum zip size: 2 MB. Files are processed in dependency order.

Query parameters

paramvaluesdefault
formatc · wasm · binarybinary
targetnative · portable · windowsnative
stdlib0 · 10
inline0 · 1 (inline runtime into C)0

Request format

The body is your U source code. Two content types accepted:

Content-Typebody format
text/plainRaw U source (the playground uses this)
application/json{"source": "f main() -> I\n\tr => 42"}

Response

For format=c: JSON with {"c": "...", "errors": [], "warnings": []}.

For format=binary or format=wasm: raw binary (set -o file in curl).

For /run: JSON with {"compiled": true, "output": "...", "exit_code": 0}.

Limits

Source size256 KB
Compile timeout15 seconds
Run timeout5 seconds
Rate limit15 requests / minute per IP
Concurrent3 compilations

Available compilers

curl -s https://compiler.ulanguage.org/health | python3 -m json.tool
# Shows: gcc, tcc, cosmocc, wat2wasm availability

Pipe to local gcc

# Get C with runtime inlined, compile locally
printf 'f main() -> I\n\tr => 42\n' | \
  curl -s -X POST -H 'Content-Type: text/plain' \
  'https://compiler.ulanguage.org/compile?format=c&inline=1' \
  --data-binary @- | python3 -c "
import sys, json
c = json.load(sys.stdin)['c']
open('prog.c','w').write(c)
print('wrote', len(c), 'bytes')
"
gcc -O2 -o prog prog.c -lm
./prog

The compiler is open source. Self-host: git clone the repo, cd compiler && python3 -m u2c.server 8081.