Duck
Tutorials9 min read

How to Build a Custom AI Floor Plan Generator (That Actually Works)

Samet Turan— Editor··9 min read

Stop wrestling with generic tools. This guide shows you how to build a custom AI floor plan generator using an image model and a simple script.

The Core Components: What You’ll Actually Need

Let’s get this out of the way first. You aren’t building a graphics engine. You’re building a data extraction pipeline. The goal of an ai floor plan generator isn’t to create a photorealistic 3D model from a text prompt. The goal is to take a messy, real-world input—like a photo of a hand-drawn sketch from a contractor’s notepad—and turn it into structured, machine-readable data. The pretty picture comes later, and it’s the easiest part.

You need three things for this to work:

  • An Image Input Mechanism: This can be a simple web form, an email inbox poller, or even a Dropbox folder watcher. Somewhere for the source images to land.
  • A Vision-Language Model (VLM): This is the core of the operation. It looks at the image and understands it. Your options are mainly OpenAI‘s GPT-4V or Anthropic‘s Claude 3 family (Sonnet or Opus are best here). These models can look at a picture of a floor plan and describe what they see in text.
  • A Data Structuring and Rendering Script: The VLM gives you text. You need code to force that text into a predictable format (like JSON) and then use that data to draw the final floor plan. This can be a Python script that generates an SVG file, or a bit of JavaScript using a library like fabric.js.

That’s it. Don’t overcomplicate it with dedicated 3D modeling APIs or complex training processes. You’re building an automation, not a new version of AutoCAD. The magic is in connecting these simple pieces in the right order.

What Most Guides Get Wrong About AI Floor Plans

Most tutorials on this topic are, frankly, useless for a real business. They fall into two traps. First, they focus on text-to-image generation. They show you a prompt like “a modern two-bedroom apartment floor plan, top-down view” sent to Midjourney. You get a beautiful, high-resolution image that looks great. The problem? It’s completely useless. It’s an artistic interpretation, not a blueprint. You can’t edit it, you can’t get measurements from it, and you certainly can’t send it to a contractor. It’s a dead end.

🤖
Recommended Reading

AI Side Hustles

12 Ways to Earn with AI

Practical setups for building real income streams with AI tools. No coding needed. 12 tested models with real numbers.


Get the Guide → $14

★★★★★ (89)

The second trap is recommending expensive, all-in-one SaaS platforms. These tools are often rigid, black-box systems that lock you into their ecosystem. They might work for a real estate agent who needs to quickly generate a generic layout for a listing, but for an operator building a custom workflow, they’re too restrictive. You can’t control the output format, you can’t integrate it with your other systems, and the per-plan cost adds up fast.

The operator’s approach is different. We don’t go from text-to-image. We go from image-to-data, and then data-to-image. By converting the sketch into structured JSON first, we create an intermediate asset that is flexible, verifiable, and easy to work with. You can store it, edit it, send it to other APIs, and then render it into any format you need—a 2D SVG, a 3D model, or even a simple list of materials. This is the only method that gives you actual control over the process.

Step-by-Step: From Napkin Sketch to Structured Data

This is where the work happens. The goal is to feed the VLM an image and get back a clean JSON object describing the floor plan. This requires a very specific, carefully engineered prompt.

Here’s the basic flow:

  1. Image Preprocessing: Before you send the image to the API, do some basic cleanup. Convert it to a consistent format (like PNG), resize it if it’s huge (models have input size limits), and maybe increase the contrast to make the lines clearer. A simple Python script with the Pillow library can handle this.
  2. The Vision API Call and Prompt: This is the heart of the system. You’ll send the image (usually as a base64 encoded string) along with a detailed text prompt to the model’s API. The prompt is not a simple question; it’s a set of instructions.
  3. Post-processing the JSON: The model will (hopefully) return a JSON string. Your script needs to parse this string, validate its structure, and handle any errors. Never trust the LLM to return perfect JSON every time, even in JSON mode. It will fail.

Your prompt is the most critical piece. It needs to be obsessively detailed. Here’s a simplified example of what a good prompt structure looks like:

You are an expert architectural assistant. Your task is to analyze the provided floor plan image and extract its structure as a JSON object. Follow these rules exactly:

1. Identify all distinct rooms. For each room, provide a name (e.g., 'Living Room', 'Bedroom 1') and its dimensions if specified.
2. Identify all walls as line segments with start and end coordinates. Assume the top-left corner is (0,0). Use relative coordinates if exact are not present.
3. Identify all doors. For each door, specify its location on a wall and its swing direction.
4. Identify all windows, specifying their location on a wall.
5. Extract any explicit measurements or labels written on the diagram.

Output ONLY a valid JSON object with the following structure:
{
"rooms": [{"name": "string", "dimensions": "string"}],
"walls": [{"start": {"x": number, "y": number}, "end": {"x": number, "y": number}}],
"doors": [{"wall_index": number, "position": number, "swing_direction": "string"}],
"windows": [{"wall_index": number, "position": number}]
}
Do not include any explanatory text or markdown formatting before or after the JSON.

This prompt tells the model its role, gives it a clear set of tasks, and defines the exact output schema. This is the foundation of a reliable ai agent framework.

Is an AI Floor Plan Generator Just a GPT Wrapper?

Yes, and that’s the point.

People dismissively call these kinds of automations “GPT wrappers,” as if that’s a bad thing. But the wrapper is the entire business. A raw API call to GPT-4V is a toy. A production system that handles image uploads, preprocesses them, manages prompt versions, validates the output, retries on failure, and renders a usable file is a product. The value isn’t in the model; it’s in the reliability and specificity of the workflow you build around it.

My biggest gripe with this process is the fragility of the VLM’s output. Even with strict instructions and JSON mode enabled, you’ll get weird errors. Sometimes it will hallucinate a field that isn’t in your schema. Sometimes it will misinterpret a smudge on the paper as a wall. You have to build defensive code to catch these errors and either fix them automatically or flag the plan for human review. It’s not a one-shot, perfect process.

But my concrete love? How astonishingly good these models are at reading terrible handwriting. I’ve fed Claude 3 Opus pictures of crumpled napkins with barely legible scribbles like “10′ 6″ ceiling” written sideways, and it extracts the measurement perfectly. That capability alone saves an immense amount of manual data entry and is something that was genuinely impossible just a few years ago.

Turning Structured Data into a Visual Floor Plan

Once you have your precious JSON object, you need to draw something. You have a few options here, ranging from simple to complex.

The simplest method is to write a script that generates an SVG (Scalable Vector Graphics) file. SVGs are just XML text files that describe shapes and lines. You can easily write a Python or Node.js script to loop through your JSON data—the walls, doors, and windows—and write out the corresponding ``, ``, and `` tags. This is fast, cheap, and produces a clean vector image that can be used anywhere.

A more interactive option is to use a JavaScript canvas library like fabric.js. Your script would feed the JSON to a simple webpage, and the JavaScript would draw the floor plan on a canvas element. This allows for client-side manipulation, like dragging rooms or adding furniture, if you need that functionality.

Finally, you can pipe the structured data to a professional tool. You could write a simple plugin for Figma or a script for AutoCAD that reads your JSON and constructs the drawing using the tool’s native elements. This is the most powerful option, as it hands off a perfectly structured, editable file to a designer or architect.

Honestly, I’d pay a service a few cents per render to avoid writing drawing code myself. A service that takes my structured JSON and returns a clean SVG for $0.02 per plan is a no-brainer. The free tier on some rendering APIs might even cover a solo operator’s needs entirely.

How to Debug When It Hallucinates a Bathroom in the Kitchen

Your generator will eventually fail in strange ways. It will misread a ’10’ as ’16’. It will connect the living room wall to the garage. It will invent a window where none exists. This is the reality of working with probabilistic systems.

Debugging isn’t about fixing the model; it’s about constraining it and validating its output.

First, always inspect the intermediate JSON. When you get a weird-looking floor plan, the first step is to look at the structured data that generated it. 99% of the time, the error will be obvious right there—a wall with coordinates that are way off, or a room with nonsensical dimensions. This tells you the problem is in the LLM’s interpretation, not your rendering code.

Second, refine your prompt. If the model consistently misses doors, add a “few-shot” example to your prompt. Include a small example of an image and the corresponding correct JSON output. This gives the model a concrete pattern to follow and dramatically improves accuracy for specific tasks. This is a core technique in any serious operator playbook.

Third, add a validation step. After you get the JSON from the VLM, you can actually make another, cheaper LLM call. You can feed the JSON to a model like GPT-3.5-Turbo or Claude 3 Haiku (which at $0.25 per million input tokens is practically free) with a prompt like: “Analyze this floor plan data. Are there any logical errors? Do any rooms overlap? Are there any disconnected walls? List any problems you find.” This AI-powered validation can catch a surprising number of logical flaws before they ever get to the rendering stage.

Building this system requires some upfront work. You have to chain the tools together, write a solid prompt, and build in some basic error handling. It’s a perfect example of a modern no code ai assembly, where the value is in the system design, not in writing complex algorithms from scratch.

Adjacent reading: deeper coverage of AI agent platforms.

If you’d rather skip the build and deploy a working version in an afternoon, we’ve packaged this entire workflow as a prebuilt, deployable system. You can find that AI automation blueprint in the deepusecase.com/vault.

— The Colophon

One AI tool. Tested. Reviewed.
In your inbox every Sunday.

~3 minute read. Real outcomes from operators, not marketers.

Free. One email per Sunday. Unsubscribe in one click.