Source Code & Info
Tab supported • Press Ctrl+Enter to Generate
Styling & Canvas Settings
API REFERENCE
REST API Documentation & Integration
Fast, lightweight code-to-image generation powered by Canvas and Shiki.
GET
/api/c2i?code=...&lang=...&title=...
Best for direct image embedding, Markdown, and <img> tags.
POST
/api/c2i
Recommended for long scripts, multi-line code, and bot/backend integrations with JSON payload.
Parameters Reference
| Parameter | Tipe | Status | Default | Keterangan |
|---|---|---|---|---|
code |
string | Wajib | - |
Teks source code yang akan dirender (jika via GET, gunakan URL encode) |
lang |
string | Opsional | "javascript" |
Bahasa pemrograman (js, ts, py, html, css, json, rs, go, cpp, c, cs, java, php, sql, sh, yaml, md, dart, kt, swift, dll.) |
title |
string | Opsional | "SpotifySearch.js" |
Nama file atau judul yang ditampilkan pada header jendela macOS |
theme |
string | Opsional | "tokyo-night" |
Tema syntax highlighting Shiki (tokyo-night, one-dark-pro, dracula, vitesse-dark, github-dark, catppuccin-mocha, nord, synthwave-84, monokai, dll.) |
bg |
string | Opsional | "midnight" |
Preset background (midnight, purple, violet, sunset, cyberpunk, ocean, dark, transparent, atau kode custom hex #121212) |
line_numbers |
boolean | Opsional | false |
Menampilkan nomor baris di samping kiri kode (true atau false) |
font_size |
number | Opsional | 16 |
Ukuran font teks kode dalam pixel (12 - 36) |
padding |
number | Opsional | 45 |
Ketebalan padding canvas luar dalam pixel (20 - 100) |
format |
string | Opsional | "jpg" |
Format output gambar (jpg, png, webp) |
Integration Examples
# 1. cURL (POST JSON)
curl -X POST "https://api.zellrayy.com/api/c2i" \
-H "Content-Type: application/json" \
-d '{
"code": "import axios from \"axios\";\n\nasync function search() {\n const res = await axios.get(\"https://api.spotify.com/v1/search\");\n return res.data;\n}",
"lang": "javascript",
"title": "SpotifySearch.js",
"bg": "midnight",
"format": "jpg",
"line_numbers": true
}' \
--output code.jpg
# 2. Node.js (Axios)
const axios = require('axios');
const fs = require('fs');
async function renderCode() {
const response = await axios.post('https://api.zellrayy.com/api/c2i', {
code: 'import axios from "axios";\nconsole.log("Hello from Code2Img!");',
lang: 'javascript',
title: 'SpotifySearch.js',
bg: 'midnight',
format: 'jpg',
line_numbers: true
}, { responseType: 'arraybuffer' });
fs.writeFileSync('output.jpg', response.data);
console.log('Saved output.jpg!');
}
renderCode();
# cURL GET direct image request
curl -o code.jpg "https://api.zellrayy.com/api/c2i?code=import+axios+from+%22axios%22&lang=javascript&title=SpotifySearch.js&bg=midnight&format=jpg"
# HTML & Markdown Embedding
<img src="https://api.zellrayy.com/api/c2i?code=import+axios+from+%22axios%22&lang=javascript&title=SpotifySearch.js&bg=midnight&format=jpg" alt="Code Screenshot" />
// WhatsApp Bot Handler (Baileys) - Supports any code length
const axios = require('axios');
async function sendCodeScreenshot(m, sock, codeText) {
const response = await axios.post('https://api.zellrayy.com/api/c2i', {
code: codeText,
lang: 'javascript',
title: 'script.js',
bg: 'midnight',
format: 'jpg',
line_numbers: codeText.split('\n').length > 3
}, { responseType: 'arraybuffer' });
await sock.sendMessage(m.chat, {
image: response.data,
caption: 'Code screenshot generated by api.zellrayy.com'
}, { quoted: m });
}
import requests
url = "https://api.zellrayy.com/api/c2i"
payload = {
"code": 'def main():\n print("Hello from Python Code2Img!")\n\nif __name__ == "__main__":\n main()',
"lang": "python",
"title": "main.py",
"bg": "midnight",
"format": "jpg",
"line_numbers": True
}
response = requests.post(url, json=payload)
with open("code.jpg", "wb") as f:
f.write(response.content)
print("Saved code.jpg successfully!")