Extract code from a screenshot, video, or PDF

Drop a screenshot, video frame, slide, or PDF that contains code — get clean source back with indentation preserved, language detected, and ready to paste straight into your editor.

Drop a PDF or image here, or browse
PDF up to 50 MB · images up to 20 MB
Processed in-flight — temporary uploads are deleted after processing.

What should we pull from this code source?

Or pick specific fields

Or describe it yourself

Skips the OCR mess of Tesseract on monospaced fonts and the manual cleanup that follows.

By ExtractFox team · Updated · How we test

Three real tests

We wrote three pieces of code, turned each into the kind of picture people actually have, and ran every picture through this page and through Tesseract 5.5.3, the open-source OCR engine most free tools are built on. Nothing below was edited. The pictures, the true source and both outputs are downloadable at the end of this section.

1. A paused video tutorial (Python)

Dark code editor frame from a video tutorial showing a Python function load_orders, with a video player progress bar at the bottom
Input: a 1280×720 frame with the player controls still on it.
ExtractFox result panel showing the extracted Python code as JSON
What this page showed for it.
import csv
from pathlib import Path


def load_orders(path: Path) -> list[dict]:
    """Read orders.csv and keep only paid rows."""
    with path.open(newline="") as f:
        rows = csv.DictReader(f)
        return [r for r in rows if r["status"] == "paid"]


if __name__ == "__main__":
    orders = load_orders(Path("orders.csv"))
    total = sum(float(o["amount"]) for o in orders)
    print(f"{len(orders)} paid orders, {total:.2f} total")
ExtractFox output (the code field): identical to the source, 0 of 444 characters wrong, player bar and window title left out.
orders.py — tutorial
import csv
from pathlib import Path
def load_orders(path: Path) -> list[dict]:
"""Read orders.csv and keep only paid rows."""
with path.open(newline="") as f£:
Tesseract, first six lines: indentation gone, the window title read as code, an f misread as f£.

2. A conference slide on a dark background (JavaScript)

Dark navy presentation slide titled Retry with exponential backoff with a JavaScript retry function
Input: slide with a title, a subtitle and one code block.
export async function retry(fn, { tries = 3, delayMs = 250 } = {}) {
  let lastError;
  for (let attempt = 1; attempt <= tries; attempt++) {
    try {
      return await fn();
    } catch (err) {
      lastError = err;
      await new Promise((r) => setTimeout(r, delayMs * 2 ** (attempt - 1)));
    }
  }
  throw lastError;
}
ExtractFox output: 0 of 326 characters wrong; the slide title stayed out of the code.
Retry with exponential backoff
Week 4 - Async patterns
export async function retry(fn, { tries = 3, delayMs = 250 } = {}) {
let lastError;
for (let attempt = 1; attempt <= tries; attempt++) {
try {
Tesseract, first six lines: the title comes first and every line loses its indentation.

3. A phone photo of a monitor (Go)

Angled, slightly blurred photo of a monitor showing a Go program with a slugify function, with glare and noise
Input: angled, blurred, glare and sensor noise. Simulated, so the true source is known exactly.
package main

import (
	"fmt"
	"strings"
)

func slugify(s string) string {
	s = strings.ToLower(strings.TrimSpace(s))
	return strings.Join(strings.Fields(s), "-")
}

func main() {
	fmt.Println(slugify("  Extract Code From Images "))
}
ExtractFox output: 0 of 235 characters wrong, tabs kept as tabs.
a
package main —
"strings" uy
func slugify(s string) string { ; : 2
s = strings. ToLower(strings. Tr |
return strings.Join(strings.Fields\s? ; 2
Tesseract, first six lines.

Results side by side

Errors are character edits (Levenshtein distance) from the true source after trimming trailing spaces. Tesseract has no idea what is code, so titles it read count against it; that is also what you'd have to clean up by hand.

PictureCharactersExtractFox errorsTesseract errorsExact lines (EF)Exact lines (Tess.)Indent right (EF)Indent right (Tess.)
Video frame44408415/150/1515/158/15
Dark slide32609612/120/1212/122/12
Phone photo23505815/150/1515/156/15

Three pictures is a demonstration, not a benchmark, and all three were clean, legible code. Where this breaks: text smaller than about 9 pixels high, code cut off at the edge of the frame, and motion blur from pausing mid-scroll. In those cases the extractor returns what it can read rather than guessing at the rest, so check the last lines.

Extract code from a video

  1. Pause where the whole snippet is on screen. If the presenter scrolls, take one frame per screenful.
  2. Switch the player to full screen and the highest quality; small, compressed frames are where characters go wrong.
  3. Take a screenshot: Cmd+Shift+4 on a Mac, Win+Shift+S on Windows, or the screenshot button on a phone.
  4. Drop the picture above. For several frames, upload them together and pick "All code blocks"; each frame comes back as its own block.
  5. Copy the code or download it. Run it once before you trust it: a presenter's code may depend on files you don't have.

You don't need to crop the player controls, subtitles or the window title; the first test above kept them in on purpose.

Languages we tested

Grid of nine short code snippets in Python, JavaScript, TypeScript, Go, Rust, Java, C#, SQL and Bash
One picture, nine snippets, extracted with "All code blocks".
SnippetLanguage detectedCode
PythonpythonExact
JavaScriptjavascriptExact
TypeScripttypescript2 characters off: indentation width
Gogo4 characters off: indentation width
RustrustExact
JavajavaExact
C#c#Exact
SQLsqlExact
Bashbash2 characters off: indentation width

Every language was named correctly. The three misses were all the same thing: indentation that was two spaces or a tab came back as four spaces. Characters and line breaks were right. If indentation width matters (Makefiles, YAML, Go formatting), say so in the box above the extract button, e.g. "keep tabs and two-space indents exactly".

When plain OCR is enough

Tesseract is free, runs offline and is very good at black text on a white page. Code is a harder case for it: indentation carries meaning, symbols like { } [ ] and => look alike at low resolution, and it has no way to tell code from the slide title or the video player around it. If your pictures are clean, high-resolution and you're happy to fix spacing by hand, it's a fine choice. If you want the code to run on the first paste, use a model that reads it as code.

Sources

  • Tesseract 5.5.3 run as tesseract image.png - --psm 6 (one uniform block of text), September 25, 2026
  • ExtractFox runs on the same images, September 25, 2026; script in the repo at scripts/samples/code.mjs, method on how we test

Frequently asked questions

How do I extract code from a screenshot?+

Drop the screenshot above, pick Clean code (or All code blocks if there are several snippets), and extract. You get the code as text with its indentation, plus the detected language, ready to copy or download.

Does it detect the language?+

Yes. In our test with nine snippets (Python, JavaScript, TypeScript, Go, Rust, Java, C#, SQL, Bash) every language was named correctly. The detected language comes back with the code so you can save the file with the right extension.

Will indentation be exact?+

Depth and structure, yes: in all three full tests every line's indentation matched. Width is the weak spot: in short snippets, two-space and tab indents sometimes came back as four spaces. If width matters, ask for it in the box above the extract button ("keep tabs exactly").

Can I extract code from a video tutorial?+

Pause on a frame where the snippet is fully visible, take a screenshot, and upload it; the player controls and window title can stay in the picture. For code that scrolls, take one frame per screen and use All code blocks.

What about REPL or Jupyter notebook screenshots?+

Pick Code and its output. Each input cell and its printed output come back separately, so you can re-run the code without the output mixed in.

Does it handle dark themes?+

Yes. Two of the three tests on this page are light text on dark backgrounds, and both came back with no errors.

Related extractors