JSON-Structured Image Decomposition: Surgical Design Edits Without Regenerating Everything

Tools:Gemini 3.1 Flash at gemini.google.com
Time to build:45–90 minutes first pass, 5–10 minutes per iteration after
Difficulty:Advanced
Prerequisites:Comfortable generating and editing images with Gemini; familiar with JSON as a data format
Gemini

What This Builds

You get a repeatable workflow for making precise, targeted edits to AI-generated images — changing a single color, swapping one element, or adjusting lighting — without the model drifting on everything else you didn't ask it to touch. The technique turns any image into a structured text blueprint. You edit the blueprint, not the image directly. The result is a reliable way to produce design variations, colorway options, and presentation mockups at a pace that free-text prompting alone cannot match.

Prerequisites

  • A Advanced account at gemini.google.com (free tier works; Advanced gives noticeably better adherence to complex JSON)
  • At least one image you want to edit or create variations of (product photo, layout mockup, branded scene)
  • Basic familiarity with JSON structure (key-value pairs, curly braces, nesting) — you don't need to write it from scratch, Gemini does that
  • A design project where you need to produce multiple variations without starting over each time

The Concept

Think of your image as a Figma file with named layers. If a client asks you to swap the button color from teal to coral, you don't redraw the entire artboard — you change one layer value. JSON-structured prompting works the same way. You ask Gemini to read your image and write out every element it sees as a labeled list with properties: object name, color, material, position. That list is your layer panel. You change the one value you want to update, then hand Gemini the original image plus the modified list and say "rebuild this according to the spec."

The model now has an explicit contract for what every element in the scene should look like. Because the unchanged elements are locked in writing, there's far less room for the model to hallucinate a new background, rotate the product, or swap your sans-serif headline for a serif one.

One more thing to understand: the JSON you extract is tunable. Ask for color and material fields if you're editing product finishes. Ask for lighting fields if you're adjusting mood. Ask for text and typographic fields if you're editing embedded copy. The schema you request shapes what the model can and can't change.


Build It Step by Step

Part 1: Extract Your Image's JSON Blueprint

Open gemini.google.com and upload the image you want to edit. Use this prompt to extract the blueprint. Adapt the field list to match what you actually need to control.

Extraction prompt (copy-paste ready):

Copy and paste this
Analyze this image and output a complete JSON representation of every visible element.

For each element include:
- "name": what the object is
- "colour": the exact color (use hex codes where you can determine them, or descriptive values like "warm white" or "deep teal")
- "material": the surface material or texture (e.g. "matte plastic", "brushed aluminum", "linen fabric", "glossy paper")
- "position": where it sits in the frame ("center foreground", "upper-left background", etc.)
- "size": relative to the frame ("large", "medium", "small", or a percentage estimate)

Also include a top-level "lighting" object with:
- "type": the light source (e.g. "soft studio", "natural window light", "dramatic side lighting")
- "direction": where light is coming from
- "mood": the overall tonal mood

Return only valid JSON. No explanation text outside the JSON block.

Copy the entire JSON response and save it somewhere you can edit it — a plain text file, a Notion page, or even a code editor with syntax highlighting.

Part 2: Make Your Surgical Edit

Read through the returned JSON and find the specific element you want to change. This step usually takes less than a minute — each object has a name, so you're just scanning a list.

Change only the field or fields you intend to modify. Leave everything else exactly as Gemini returned it.

Example: You want to change a product's colorway from navy to terracotta.

Find the product object in your JSON. It might look like:

Copy and paste this
{
  "name": "product body",
  "colour": "#1B2A4A",
  "material": "matte plastic",
  "position": "center foreground",
  "size": "large"
}

Change only the colour value:

Copy and paste this
{
  "name": "product body",
  "colour": "#C0674B",
  "material": "matte plastic",
  "position": "center foreground",
  "size": "large"
}

Everything else in the JSON stays identical. That's the whole edit.

Part 3: Re-Apply the Modified JSON to the Original Image

Start a fresh Gemini conversation. Upload the original image again — the same one you extracted the JSON from, not a previous edit. Paste your modified JSON into the prompt along with this instruction:

Re-application prompt:

Copy and paste this
Modify this image based on the following JSON specification. Apply every value in the JSON exactly as written. Do not change any element that is not explicitly different from what you see in the original image.

[paste your modified JSON here]

Review the output. If Gemini changed something you didn't ask it to change, go back to the JSON and find the field that is implicitly triggering the drift. Add that element back explicitly to the JSON with its original value. Re-apply. This usually resolves the issue in one additional round.


Real Example: Product Packaging Colorway Sheet

The brief: A packaging client needs to see their new coffee bag design in five colorways before choosing one for production. The original design is a single AI-generated studio mockup on a white background. Producing five variations by re-prompting in natural language keeps drifting: the label shifts position, the bag changes shape, the lighting flips sides.

Setup: Upload the original packshot to Gemini. Extract the JSON blueprint using the prompt above. The returned JSON identifies: bag body, label panel, logo mark, background, and lighting.

The edit sequence:

  1. Change bag body colour from "#2C2C2C" (matte black) to "#8B3A3A" (deep red). Re-apply. Save output.
  2. Return to original JSON. Change to "#1A3A5C" (navy). Re-apply. Save output.
  3. Repeat for sage green, warm sand, and charcoal slate.

Each edit takes 3–5 minutes. All five variations have the same bag shape, label placement, logo, shadow, and lighting. The client can compare colorways directly without your eye being drawn to inconsistencies.

Input: 1 original image plus 5 simple JSON edits. Output: 5 consistent product variations ready for client presentation. Time saved vs. re-prompting: A free-text approach for five consistent variations typically takes 45–90 minutes of prompt iteration. This workflow takes 20–25 minutes total.


What to Do When It Breaks

The model changed something I didn't ask it to change. Add that element explicitly to your JSON with its original value. The model drifts on elements that aren't pinned in the spec. Pinning them stops the drift.

The JSON Gemini returned is very long and hard to read. That's normal for complex scenes. You don't need to read every field. Search (Ctrl+F) for the element name you want to change. Edit that object. Leave the rest.

The color I asked for isn't accurate in the output. Describe the color more specifically. Instead of "red", use "#C0674B" or "muted terracotta, similar to unglazed clay". Hex codes plus a plain-language descriptor together give the model more to anchor to.

Gemini refuses to edit the image or returns text only. Make sure image generation is enabled in your Gemini settings. If you're on the free tier, switch to gemini.google.com and try again. AI Studio (aistudio.google.com) is a free fallback that uses the same underlying model.

The extracted JSON doesn't include an element I need to control. Re-run the extraction prompt with that element explicitly called out: "Also include any embedded text as a 'text_elements' array with 'content', 'font_style', 'colour', and 'position' fields."


Variations

Lighting mood transfers. Build a JSON schema focused only on lighting fields (type, direction, color temperature, time of day, shadow hardness). Extract from two images — your subject and a reference image with the lighting you want. Replace only the lighting block in your subject's JSON with the lighting block from the reference. Re-apply.

Brand color compliance. Before extraction, note your brand's hex values. After extraction, search every "colour" field in the JSON and replace any off-brand values with the correct hex. Re-apply to generate a version of any scene that is brand-compliant throughout.

Embedded text swaps. Add a "text_elements" array to your extraction prompt. Once extracted, change "content" values to swap headlines, labels, or taglines. Useful for social media template variations or localization.

Multi-image object merges. Extract JSON from two separate images. Copy a specific object's JSON block from image B into image A's JSON (replacing the equivalent object). Upload image A with the merged JSON. This lets you, for instance, place a product from one photo into a scene from another while keeping both images' original lighting and proportions.


What to Do Next

Build a small library of JSON blueprints for your most-repeated design assets: your client's product, your standard mockup scenes, your go-to lighting setups. Store them as text files alongside your project folders. When a new variation request comes in, you open the blueprint, make the edit, and re-apply. No extraction step needed.

From there, consider what the technique can't do cleanly yet: fine typographic control (kerning, tracking, specific fonts), precise geometric layout work, and print-ready color accuracy. Those still belong in your production tools. The JSON workflow is strongest for client-facing iteration and concept approval — the stage where clients need to see options, not the stage where you're building the final file.


Advanced guide for graphic designer professionals. These techniques use more sophisticated AI features that may require paid subscriptions. Pricing and feature availability: $20/month.