Skip to content

Extract Code from an Image

Turn a screenshot of code from a tutorial, video, slide or chat into text you can paste into your editor. Dark themes work. Check the symbols, fix the indentation, run it.

Paste or drop a code screenshot

Supports JPG, JPEG, PNG, GIF, BMP, WebP, TIFF, HEIC, HEIF, HEICS

Auto detects the writing system and reads it. For better results, pick the language (up to 3 if the text mixes languages).

Press Ctrl+V (Cmd+V on Mac) or drop a screenshot of code here

or

Max file size: 10MB

More OCR Tools

Convert different image formats to text with our specialized OCR tools

By task

By file type

Key takeaways

Can OCR read code?
Yes. Code in a clear monospace font reads well. The OCR reads characters, not programming languages, so it does not check syntax.
What needs checking?
Lookalike characters (l and 1, O and 0, quotes and backticks) and indentation, which is usually lost. Re-indent with your editor’s formatter.
Is my code private?
Yes. The screenshot is read in your browser and not uploaded, which matters for work code, keys and logs.

How to extract code from an image

Screenshot the code, paste it here, then clean the result up in your editor.

Last updated:

  1. 1

    1. Screenshot the code

    Zoom the code to a comfortable reading size, then take a screenshot of just the code block. A paused video frame works too.

  2. 2

    2. Paste and extract

    Press Ctrl+V on this page or drop the file (up to 10 MB), choose English as the language, and click Extract Text.

  3. 3

    3. Fix and format

    Paste into your editor, run its formatter to restore indentation, and check symbols before you run the code.

Extract code now

Useful for code screenshots

What helps when the image is code rather than prose.

Why extract code from an image?

Benefits

  • No retyping code from video tutorials and slides
  • Copy error messages exactly so you can search for them
  • Get config snippets and commands out of screenshots in chats
  • Free, with nothing to install

Tips for clean code OCR

  • Use a large monospace font and crop out line numbers if you can
  • Prefer a screenshot over a photo of the screen
  • Pick English as the OCR language for code; add a second language if the comments use one

Where code screenshots come from

Our image to text converter is designed to streamline the process of extracting text from images. However, we understand you might have a few questions. To make the most of this tool, we've compiled some frequently asked questions along with helpful explanations to guide you.

How do I extract code from an image?

Take a screenshot of the code, open this page and press Ctrl+V or drop the file. Click Extract Text, paste the result into your editor and run its formatter.

Does it keep indentation?

Usually not. OCR returns the lines of code but leading spaces are often lost. Re-indent with your editor’s formatter (for example Prettier or Black) after pasting.

Why are some symbols wrong?

Some characters look almost identical in many fonts: l, 1 and I; O and 0; straight and curly quotes; backticks. Check these, especially in strings and identifiers.

Does it work with dark editor themes?

Yes. Light text on a dark background is detected and inverted before reading.

Which programming languages does it support?

Any, because the OCR reads characters, not syntax. Choose English as the OCR language for code; add a second language if comments are written in it.

Can I extract code from a video?

Yes, from a paused frame. Pause the video where the code is fully visible, take a screenshot and paste it here. See Screenshot to Text for capture shortcuts.

Is my code uploaded anywhere?

No. The OCR runs in your browser, so source code, keys and logs stay on your device.

Latest from Our Blog

Tips, guides, and insights on OCR technology

View All Posts

· How-to

How to Extract Text From a Screenshot

Turn a screenshot into editable text: capture it, paste it straight into a free browser OCR, and copy the result. Shortcuts for Windows, Mac and phones.

This tool in other languages

Ad Sponsored Check this offer
Ad Sponsored Check this offer