Opan AI Codex Make CSS From Images: Prompts, Examples, and Free Options
Hand a screenshot, a mockup, or a photo of a layout to OpenAI Codex and get working CSS back. This article shows the exact prompts, three worked examples, the free access that exists today, and free alternatives on PicassoIA.
You have a screenshot of a page you like, or a mockup from a designer, and you need the CSS by the end of the day. Typing every margin, shadow and grid column by hand is slow. That is why so many people search for Opan AI Codex make CSS from images (the product is spelled OpenAI Codex) and hope the tool can read a picture and hand back a stylesheet. It can, within limits, and the result depends far more on your prompt than on the tool.
This article shows what Codex does with an image, the prompts that give clean CSS, three worked examples, what free access looks like right now, and where to go if you want free alternatives that run in your browser.
💡 Quick answer: Upload the image, tell Codex the stack you use (plain CSS, Tailwind, CSS modules), name the breakpoints, and ask it to compare its render with your image. Those four instructions fix most bad output.
What Codex Does With Images
OpenAI Codex is a coding agent. You give it a task, it reads your project files, edits them, and runs commands. Because it accepts image input, you can attach a screenshot to that task and say "make the page look like this."
Image input in plain terms
The model looks at your picture the way a person would glance at a design comp. It picks out the header bar, the hero block, the card grid, the button radius, the rough font weight and the color palette. Then it writes HTML and CSS that approximate what it saw.
Notice the word approximate. It does not read exact pixel values from a flat image. A shade like #2F6FED may come back as #2E6EE8. Spacing arrives as a good guess, not a measurement.
Screenshot, mockup, or photo
Not every image works equally well. Here is how the three common inputs behave:
Input type
Accuracy
Best use
Clean screenshot
High
Rebuilding a page layout you already have
Design mockup export
High
Turning a comp into a first stylesheet
Photo of a screen or a sketch
Medium to low
Rough structure only
Hand drawn wireframe
Medium
Grid and section order, not styling
A flat screenshot at normal size gives the best result. A photo of a monitor adds glare, skew and moire patterns, and the model may read those as design choices.
Prompts That Produce Clean CSS
A bare "turn this into CSS" works, but it leaves too much open. The model will invent class names, pick a random unit system and ignore responsive behavior. Give it constraints.
The base prompt
Use this as your starting point and swap in your own details:
Build the layout in the attached image as semantic HTML and plain CSS.
Use CSS custom properties for colors and spacing.
Use CSS grid for the card section and flexbox for the header.
Mobile first, with breakpoints at 640px and 1024px.
Name classes with BEM. No frameworks, no inline styles.
After writing it, render the page, compare it to the image,
and list the differences you still see.
The last two lines matter most. Asking for a comparison pushes the agent to check its own work, and it will often catch an off-center button or a wrong gap before you do.
A prompt for design tokens
Sometimes you do not want a page, only the values. Try this:
Look at the attached image. Extract a design token set as CSS variables:
primary, secondary and neutral colors, border radius scale,
shadow levels, spacing scale based on 4px, and font size scale.
Output only a :root block with comments for where each token is used.
You get a short, reusable file instead of a pile of one-off values. This is the cleanest way to bring a brand look into an existing codebase.
A prompt for responsive behavior
A single image shows one screen size. The model has to guess the rest. Tell it what should happen:
The image shows the desktop view at 1440px.
At 768px the three cards become two columns.
At 480px they stack and the header collapses to a menu button.
Keep the hero text centered at every size.
Without that, the cards may overflow on a phone, since nothing in the picture says otherwise.
💡 Tip: If you have both a desktop and a mobile image, attach both and label them. Say "image 1 is desktop, image 2 is mobile." Two references remove most of the guessing.
Real Examples You Can Copy
These three cases come up all the time. For each, the prompt and the thing to watch for.
Example one: a pricing card
Attach a screenshot of a three-tier pricing section and send:
Recreate the pricing section from the image.
The middle card is highlighted: slightly larger, with a colored border.
Use grid with equal column widths and a 24px gap.
Buttons are pill shaped with a hover state that darkens by 8%.
Expect the structure to be right on the first pass. Expect to adjust the highlighted card's scale, because "slightly larger" is vague. Replace it with transform: scale(1.04) in your prompt if you want precision.
Example two: a hero section
Attach a hero banner with a headline, a sub line, two buttons and a photo on the right:
Build this hero as a two column layout.
Text left, image right, vertically centered.
The headline uses clamp() so it scales between 2rem and 3.5rem.
On screens under 768px put the image above the text.
Use object-fit: cover on the photo with a 16 by 9 ratio.
Here the model usually does well, since a hero is a simple pattern it has seen thousands of times. The common slip is the image crop, so check it on a narrow screen.
Example three: fixing a layout bug
This one is where image input shines for existing projects. Take a screenshot of the broken page and send:
This screenshot shows a bug: the sidebar overlaps the main content
at about 900px wide. Find the CSS causing it in this repo,
fix it with the smallest change possible, and explain what was wrong.
Because Codex can open the files, it can match what it sees in the picture to a rule in your stylesheet. A typical cause is a missing min-width: 0 on a flex child, or a position and z-index clash. Ask for the smallest change so it does not rewrite files you did not want touched.
💡 Tip: After any fix, ask for a screenshot of the result at three widths. A fix that works at 900px can break at 700px.
Free Options Right Now
People ask whether this can be done for free. The honest answer has two parts.
Free ChatGPT account access
Codex can be reached with a free ChatGPT account, but the access is limited. OpenAI does not publish a clear number of tasks you get on the free tier, and the cloud version of Codex is not part of it. Usage limits also change often, so check the current pricing page from OpenAI before you plan a project around it.
One more point from my research: OpenAI's docs state that image generation is not available on the free plan. That is about creating pictures, not necessarily about attaching one to a coding prompt, and I could not confirm how image uploads are treated on the free tier today. The safest move is to try a single screenshot and see what happens.
Access route
Cost
Practical limit
Free ChatGPT account
Free
Limited, unpublished allowance
Paid ChatGPT plans
Monthly fee
Higher allowance, image use counts faster than text
API key
Pay per use
Billed by tokens, images included
On paid plans, a task with images uses your allowance faster than a text-only one, so a long session of screenshot prompts can run down the balance sooner than you expect.
Other free routes worth trying
Open source screenshot to code projects exist, but they usually call a paid model behind the scenes, so the software is free while the inference is not. If you want a no-install option, the next section covers models on PicassoIA that accept an image and can write CSS in the same way.
How to Get Similar Results on PicassoIA
Codex is an OpenAI product and is not on PicassoIA. For similar results today, the closest match is GPT 5.6 Sol, a coding focused model with image input. You get the image to CSS part of the workflow in a browser, with no setup. What you do not get is Codex's agent behavior, so it will not open your repo or run your build. You paste the output into your project yourself.
Upload your screenshot or mockup in the image input field.
Paste the base prompt from earlier in the prompt box.
Add a system prompt such as "You are a senior front end developer who writes clean, accessible CSS."
Run it, copy the code into a local file, and open it in your browser.
If something is off, reply with the specific difference, for example "the card gap is too tight, use 24px".
Settings worth changing
reasoning_effort: the default is none, which is fast. Raise it to medium or high for dense layouts with many nested sections.
verbosity: set to low if you only want the code, high if you also want notes on each rule.
max_completion_tokens: raise it when you use higher reasoning, since long thinking can use the whole budget and leave an empty reply.
Other models that read images
Two more models on PicassoIA are worth a try for the same job:
Claude Sonnet 5 accepts an image and has an effort setting from low to max. It is a good choice when you want tidy, readable code with sensible class names.
Gemini 3.5 Flash takes up to 10 images per prompt, which helps when you have desktop, tablet and mobile views to send together.
GPT-4o is a lighter option for quick, simple layouts.
Running the same screenshot through two of these and comparing the CSS is a cheap way to find which one matches your coding style.
Common Mistakes to Avoid
Most disappointing results come from the same handful of causes.
Sending a low quality image
A blurry or tiny screenshot gives the model nothing to read. Use a sharp capture at its normal size, and crop out browser chrome and desktop clutter.
Asking for everything at once
A full landing page in one prompt produces long, tangled CSS. Build in pieces: header first, then hero, then cards, then footer. Each piece gets checked before you move on.
Leaving the stack unspecified
If you do not name your tools, you may get Tailwind classes when you use plain CSS, or the other way round. Say it in the first line.
Trusting colors and fonts blindly
The model reads color from pixels, so it drifts. If you have the real hex codes and font names, put them in the prompt. A short list beats a guess every time.
Skipping the browser check
Always open the result at several widths. CSS that looks right at 1440px is often broken at 800px, and the model will not know unless you tell it.
The rule of thumb is simple. If the job lives inside a project folder, use an agent like Codex. If the job is "make this picture into code," a browser model is faster and often cheaper.
Try It on Your Own Screenshot
Pick one real page you want to rebuild. Take a sharp screenshot, copy the base prompt from this article, and run it. Then run the same image through a second model and compare the two stylesheets side by side.
On PicassoIA you can do that in a few minutes: open GPT 5.6 Sol, upload your image, paste the prompt, and see what comes back. Then try Claude Sonnet 5 or Gemini 3.5 Flash with the same file. If your page also needs photos, hero banners or product shots, you can generate those on the platform too, and browse every model at picassoia.com/en/all-models.
Start with a single section, keep your prompts specific, and check the result in the browser. The first draft will be close. The second prompt, where you point out what is off, is where it gets right.