DEV Community

Cover image for How I Built a Free Image-to-Prompt Tool with Next.js and a Vision Model
Youssef elabbassi
Youssef elabbassi

Posted on

How I Built a Free Image-to-Prompt Tool with Next.js and a Vision Model

Recently, I kept hitting the same wall in AI art: I'd find an image with a style I loved, but recreating it in Stable Diffusion or Midjourney meant guessing at the prompt for far too long. Writing prompts from scratch is slow and inconsistent.

So I built the reverse: a tool where you upload an image and get a detailed, ready-to-use prompt back. This post walks through how it works and the decisions behind it.

Live version: ImagePromptNow

The core idea

Instead of prompt → image, go image → prompt. Feed a picture into a vision-language model, and format its output into a prompt describing the subject, style, lighting, and composition — something you can paste straight into Midjourney, Flux, Stable Diffusion, or DALL-E.

The whole product is really just three things:

  1. An upload flow (file or image URL)
  2. A vision model call
  3. Output formatting into a usable prompt plus a structured breakdown

The stack

  • Next.js (App Router) for the frontend and API routes
  • next-intl for localization — the tool ships in 6 languages
  • A vision-language model (Llama 3.2 11B Vision) for image analysis
  • A CWP-based VPS for hosting, with the worker running separately

Nothing exotic. The interesting parts were the prompting and the deployment, not the framework.

Getting good prompts out of a vision model

The naive approach — "describe this image" — gives you a caption, not a prompt. A caption reads like "a man sitting on a yellow swing." A prompt needs structure: subject, setting, style, lighting, camera, mood.

The fix was instructing the model to return the description in a specific order and level of detail, then post-processing it into a clean prompt. I also expose a "structured breakdown" so users can see how each element maps back to the image, which makes it easier to tweak specific parts.

A few lessons:

  • Clear, well-lit images produce dramatically better prompts than busy or dark ones.
  • Over-describing hurts. A prompt bloated with every detail generates worse art than a focused one.
  • Different models want different phrasing. Stable Diffusion likes keyword-style prompts; DALL-E and Flux prefer natural language. Giving users one solid base prompt they can adapt beat trying to auto-target each model.

Localization was worth it early

I added next-intl and 6 languages sooner than most people would. The payoff showed up fast in search: non-English pages started ranking within days, in markets where competitors only ship English. If you're building anything content-adjacent, localization is underrated distribution.

Deployment gotchas

The site runs on a CWP7pro VPS behind Apache with a Next.js reverse proxy. One sharp edge: AutoSSL renewals would wipe the proxy vhost config and take the site down with a 403. The fix was a small watchdog cron that re-inserts the ProxyPass block if it goes missing. Not glamorous, but it turned a recurring outage into a non-issue.

Another one specific to Next.js on a monorepo: apps/web had "type": "module" in its package.json, so any helper Node scripts inside it had to use the .cjs extension or they'd throw ESM errors.

Keeping it free and frictionless

I made three deliberate choices that shaped everything:

  • No login. You should be able to try it in one click.
  • No usage limits. Nothing kills experimentation like a credit counter.
  • No paywall on the core feature.

These aren't just nice-to-haves — they're the product. The friction-free path is what makes people actually use and share a tool like this.

What's next

The most requested feature so far is an inline-editable prompt with the ability to "lock" certain visual elements before regenerating — keep the subject, change the style, that kind of thing. That's next on my list.

If you want to try it, it's here: ImagePromptNow — no signup, and I'd genuinely welcome feedback, especially on prompt quality versus what you'd write by hand.

Thanks for reading!

Top comments (0)