DEV Community

maqiang ma
maqiang ma

Posted on Fully Autonomous

A tiny JavaScript prompt builder for controlled AI image experiments

When a visual draft misses the mark, changing the subject, style and lighting together makes it hard to understand which change helped. A small structured prompt makes your next experiment easier to compare.

Here is a browser-independent JavaScript example. It creates two prompt strings; it does not call an image API or require a package.

const fields = ["subject", "setting", "style", "lighting", "composition"];
const base = {
  subject: "an amber perfume bottle",
  setting: "on travertine beside a blood orange",
  style: "editorial product photography",
  lighting: "warm side lighting",
  composition: "empty space on the left"
};

const experiments = [
  { label: "baseline", change: {} },
  { label: "lighting-only", change: { lighting: "soft overcast light" } }
].map(({ label, change }) => {
  const scene = { ...base, ...change };
  return { label, prompt: fields.map(key => scene[key]).join(", ") };
});

console.table(experiments);
Enter fullscreen mode Exit fullscreen mode

Keep the comparison small

Generate a baseline, then try the lighting-only prompt. Keep the same available aspect ratio and reference image, if you are using one. Save the prompt and result together, with a short note such as “bottle edges clearer” or “background too busy.” Change composition in a separate experiment.

This is a way to organize creative exploration, not a guarantee of a controlled scientific result. Image generation can vary between runs, even when the written prompt stays the same. A prompt log tracks your instructions; it does not make the underlying generator deterministic.

Try it in a browser

We are sharing this workflow alongside FreeGenArt, our Free AI Image Generator — No Sign-Up. It supports text prompts and reference-image workflows online, with a daily free image allowance. Paste either prompt into the generator; this example is not an API integration.

Before using a result, inspect lettering, reflections, object boundaries and any details that matter to your project. For reference-image experiments, use material you have permission to upload.

You can extend the same object with a mood or color palette later. Start with a few fields you can compare meaningfully, then add detail when a particular direction needs it.

Disclosure: this write-up and example were prepared with AI assistance. FreeGenArt is our product.

Top comments (1)

Collapse
 
will_laurenson_c16056cd19 profile image
Will Laurenson •

A prompt builder like this could also help keep a useful record of each experiment. Saving the exact prompt alongside the model, seed and generation settings would make it much easier to revisit a good result later. Even a simple JSON export could be handy, so the tool stays lightweight while still making experiments easier to reproduce.