API Documentation

URL-based configuration and OG Image API for generating code screenshots programmatically.

URL Parameters

You can configure CodeTarz via URL parameters to create shareable links.

GET/editor?code={base64}&lang={language}&theme={theme}

Open editor with pre-configured code and settings.

ParamTypeDescription
codestringBase64 encoded code string (btoa(encodeURIComponent(code)))
langstringLanguage identifier (e.g., typescript, python, rust). Default: typescript
titlestringFile title (e.g., app.tsx). Default: untitled.ts
themestringTheme ID (e.g., one-dark, dracula, github-light). Default: one-dark
bgnumberBackground index (0-21). Default: 0
fontnumberFont index (0-5). Default: 0 (JetBrains Mono)
fontSizenumberFont size in pixels (10-24). Default: 14
paddingnumberPadding in pixels (16-80). Default: 40
radiusnumberBorder radius in pixels (0-32). Default: 12
opacitynumberCode card opacity (80-100). Default: 100
windowstringWindow style: macos, windows, none. Default: macos
linesstringShow line numbers. Set to "0" to hide. Default: shown
watermarkstringShow watermark. Set to "1" to enable. Default: hidden
noisestringEnable noise texture. Set to "1" to enable. Default: off
badgestringShow "Made with CodeTarz" badge. Set to "1" to enable. Default: hidden
badgePosstringBadge position: bottom-left, bottom-right. Default: bottom-left
gc1stringCustom gradient color 1 (hex, e.g., #ff0000)
gc2stringCustom gradient color 2 (hex, e.g., #0000ff)
ganumberCustom gradient angle in degrees. Default: 135
URL
/editor?code=Y29uc3QgeCA9IDU7&lang=typescript&theme=dracula&bg=0&padding=40

Share URL

Share code snippets with rich social media preview cards (OG images).

GET/s?d={encoded}

Shareable link that generates OG meta tags and redirects to the editor. The d parameter contains all settings encoded as base64(encodeURIComponent(JSON.stringify(data))).

ParamTypeDescription
dstringBase64-encoded JSON containing code, language, title, theme, bg, font, fontSize, padding, borderRadius, windowStyle, showLineNumbers, headerText, footerText
URL
/s?d=eyJjb2RlIjoiY29uc3QgeCA9IDU7IiwibGFuZ3VhZ2UiOiJ0eXBlc2NyaXB0In0=

OG Image API

Generate Open Graph images dynamically for social media previews.

GET/api/og?code={base64}&theme={theme}&title={title}

Returns a PNG image (1200x630) suitable for og:image meta tag.

ParamTypeDescription
codestringBase64 encoded code string
dstringFull share data (base64 JSON). Alternative to code param
themestringTheme ID (default: one-dark)
titlestringTitle text on the image
URL
/api/og?code=Y29uc3QgeCA9IDU7&theme=dracula&title=My%20Code

Available Themes

All supported code themes with their IDs.

One Dark Proone-dark
Draculadracula
Night Owlnight-owl
GitHub Darkgithub-dark
Solarized Darksolarized-dark
Catppuccin Mochacatppuccin
Monokaimonokai
Tokyo Nighttokyo-night
GitHub Lightgithub-light
Catppuccin Lattecatppuccin-latte
Solarized Lightsolarized-light
Min Lightmin-light

Supported Languages

18 programming languages with full syntax highlighting.

JavaScriptTypeScriptPythonRustGoJavaC++HTMLCSSSQLBashJSONYAMLMarkdownPHPRubySwiftKotlin

Preset Templates

Available preset configurations for social media optimization.

Twitter Post1200x675 optimized, padding 48, watermark enabled
twitter
LinkedIn Card1200x627 optimized, padding 56, watermark enabled
linkedin
Blog HeroWide format, font size 15, padding 64
blog-hero
Instagram1080x1080 square, no window controls, watermark enabled
instagram
Presentation16:9 slide format, font size 16, padding 56
presentation
MinimalNo window controls, no line numbers, padding 24
minimal
DocumentationNo window controls, compact, font size 13
documentation

Usage Examples

Common usage patterns.

Share via URL parameters

JavaScript
const code = btoa(encodeURIComponent(`const x = 5;
const y = 10;
console.log(x + y);`));
const url = `https://codetarz.dev/editor?code=${code}&lang=javascript&theme=dracula`;
console.log(url);

Share via encoded link (with OG preview)

JavaScript
const data = JSON.stringify({
  code: 'const x = 5;',
  language: 'typescript',
  title: 'example.ts',
  theme: 'dracula',
  bg: 0, font: 0, fontSize: 14, padding: 40,
  borderRadius: 12, windowStyle: 'macos', showLineNumbers: true,
  headerText: '', footerText: ''
});
const encoded = btoa(encodeURIComponent(data));
const url = `https://codetarz.dev/s?d=${encoded}`;

Embed OG Image in HTML

HTML
<meta property="og:image" content="https://codetarz.dev/api/og?code=Y29uc3QgeCA9IDU7&theme=one-dark&title=My%20Project" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />

Use in Markdown

Markdown
![Code Example](https://codetarz.dev/api/og?code=Y29uc3QgeCA9IDU7&theme=dracula)