Skip to content
OddsockLocal
Local
Source text

Formatting

5 wordsRuns in this browser. Nothing is uploaded.

How to use

  1. Paste the source. Empty source is rejected.
  2. Choose Language and Theme. Dark and JavaScript are the start.
  3. Set Font size and Tab width if 18px and 4 spaces are wrong.
  4. Download the PNG. A line that makes the image enormous is refused.

What is Code to image?

Code to image draws the snippet you paste onto a PNG, with syntax colors and a solid background. Language defaults to JavaScript, theme to dark, font size to 18, tab width to 4. A dark card uses a near-black background and a light foreground. Keywords, strings, numbers and comments take their own colors. const n = 1; is enough to see the keyword color on const and the rest of the line in the base color. Light theme swaps the palette.

Read more

Tabs are expanded to spaces before measuring, using the tab width, so a tab does not become a single skinny glyph. The padding around the code equals the font size, and each line is one and a half times the font size tall. A very long line or a huge font can make the picture too large, and the page refuses rather than clipping. The source itself is capped at 100,000 characters. Empty input is an error.

The PNG is produced in the tab. A snippet you would not paste into a chat is still only on this machine unless you download it and send it. Languages include JavaScript, TypeScript, CSS, XML, JSON, Python, Bash, SQL and plain text.

Use cases

  • A slide needs const n = 1; as a dark card, with const in the keyword color, instead of a screenshot of an editor.
  • A post should show a SQL or Python fragment without the surrounding IDE chrome.
  • Tabs in the snippet should become four spaces so the PNG matches the indent you intended.
  • A light card is for a printed handout. The theme switch is that choice, not a filter on a photo.

One JavaScript line on a dark card

Language javascript, theme dark, font size 18, tab width 4. Source: const n = 1;

A PNG. The background is the dark theme. const is drawn in the keyword color, and the rest of the line in the base text color. Padding equals the 18px font size.

Why use Oddsock

The card is a picture of the tokens, not a photo of your editor. Tabs are spaces before the line is measured, so the indent does not depend on the font’s tab stop.

Related tools

Using this tool

JavaScript, TypeScript, CSS, XML, JSON, Python, Bash, SQL and plain text. Plain text is one color. The others use syntax colors from the highlighter.