Prompt Variable Extractor

Paste any AI prompt, LLM system message, or template string to instantly extract all dynamic variable placeholders ({{var}}, ${var}, {var}, <var>) and auto-generate JSON schemas, mock test payloads, and LangChain definitions.

0 Characters

How to Use the Prompt Variable Extractor

1

Enter Prompt or Template

Paste your prompt containing dynamic variables (e.g. {{company}}, ${role}), upload a prompt file, or click Sample.

2

Select Syntax & Format

Filter by specific placeholder syntax or choose your preferred output format: JSON Schema, Mock JSON, or LangChain.

3

Copy or Export

Click Extract Variables to inspect detected variable positions, copy individual variable tags, or download the full schema report.

Tool Options

Syntax Pattern Filtering

Filter placeholders by template standard: Mustache/Jinja ({{var}}), ES6 Literals (${var}), Python/LangChain ({var}), XML (<var>), or SQL (:var).

4 Output Generator Views

Switch between an interactive Table Breakdown, Draft 2020-12 JSON Schema for OpenAI Structured Outputs, Mock JSON Payload dictionary, or LangChain Python snippet.

RFC 4180 CSV & Position Tracking

Download structured CSV reports containing variable names, matched syntax variants, duplicate occurrence counts, and exact Line/Column coordinate positions.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the Prompt Variable Extractor do?

The Prompt Variable Extractor automatically parses AI prompts, system instructions, and LLM prompt templates to detect, isolate, and index all dynamic variable placeholders. It supports Mustache / Handlebars / Jinja ({{var}}), Template Literals (${var}), Python f-strings & LangChain ({var}), XML Tags & Angle Brackets (<var>), Windows Environment (%var%), and SQL Named Parameters (:var), instantly generating JSON schemas, mock test dictionaries, and LangChain input arrays.

Core Concepts

Understanding prompt variables in modern AI workflows:

  • Zero-Friction Template Migration: Different prompt management tools and orchestrators use varying delimiter standards. This extractor identifies all variations in a single pass.
  • Automated JSON Schema Generation: LangChain, Semantic Kernel, and OpenAI Structured Outputs require strict parameter schema definitions. The extractor compiles detected variables into Draft 2020-12 JSON Schema objects ready for API integration.
  • Duplicate & Position Tracking: Reports both unique variable lists and exact line/column coordinates for every placeholder reference across your prompt.
  • WebMCP Integration: Enables autonomous AI coding assistants, agent browser extensions, and local LLMs to query prompt schemas via local Model Context Protocol (MCP) tool calls.

How to use the tool?

  1. Enter Prompt or Template: Paste your AI prompt into the editor, click Upload, or click Sample.
  2. Filter by Syntax Pattern: Select All Syntaxes or narrow down to a specific format like {{var}}, ${var}, or {var}.
  3. Choose Output Generator View: Switch between Variable Breakdown Table, JSON Schema, Mock JSON Payload, or LangChain Python Snippet.
  4. Copy or Export: Click Copy Variables to copy the selected format or Download JSON to export the structured schema report.

Context-Aware Practical Workflow Guides

IDE Shortcuts & LLM Orchestration

  • VS Code: Use Ctrl+F (Cmd+F on macOS) with regex \{\{([^}]+)\}\} to quickly highlight Handlebars variables in prompt files.
  • LangChain / LangSmith: Export the generated PromptTemplate(input_variables=[...]) snippet directly into your Python backend codebase.

Related Developer Utilities

  • AI Token Counter: Calculate token counts, subword metrics, and prompt costs across leading AI models.
  • AI Text Chunker: Partition large documents and prompt inputs into model-friendly context chunks.
  • JSON Formatter: Format and validate JSON schemas for LLM tool calling.
  • YAML to JSON Converter: Convert YAML prompt templates into JSON manifests.

REST API Integration

blueutils.com provides a free REST API endpoint (POST https://blueutils.com/api/ai/extract-prompt-variables) for programmatic variable extraction.

API Request Parameters

Name Type Description Example
rawText String The prompt string or template to analyze. "Hello {{user_name}}, welcome to ${company}."
syntax String Optional syntax filter (default: "all"). "double_braces"

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/ai/extract-prompt-variables \
  -H "Content-Type: application/json" \
  -d '{
    "rawText": "Explain the architectural setup for {{project_type}} using ${framework} with <security_level>."
  }'

Python

import requests

url = "https://blueutils.com/api/ai/extract-prompt-variables"
payload = {
    "rawText": "Explain the architectural setup for {{project_type}} using ${framework}."
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "rawText": "Explain the architectural setup for {{project_type}} using ${framework}."
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/ai/extract-prompt-variables"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether extraction succeeded. true
variables Array Array of extracted variable metadata objects. [{ "name": "project_type", "occurrences": 1 }]
uniqueCount Number Count of distinct variable names. 2
totalOccurrences Number Total references across prompt. 3
jsonSchema Object Draft 2020-12 JSON Schema object for tool calling. { "type": "object", "properties": ... }

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "uniqueCount": 2,
  "totalOccurrences": 2,
  "varNames": ["framework", "project_type"],
  "variables": [
    {
      "name": "framework",
      "rawMatches": ["${framework}"],
      "syntaxTypes": ["dollar_braces"],
      "occurrences": 1,
      "positions": [{ "line": 1, "column": 52 }]
    },
    {
      "name": "project_type",
      "rawMatches": ["{{project_type}}"],
      "syntaxTypes": ["double_braces"],
      "occurrences": 1,
      "positions": [{ "line": 1, "column": 30 }]
    }
  ],
  "jsonSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "framework": { "type": "string", "description": "Value for template parameter \"framework\"" },
      "project_type": { "type": "string", "description": "Value for template parameter \"project_type\"" }
    },
    "required": ["framework", "project_type"]
  },
  "sampleJson": {
    "framework": "<framework_value>",
    "project_type": "<project_type_value>"
  }
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Invalid input: Prompt payload cannot be empty."
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to extract prompt variables?

  • Dynamic Template Validation: Automatically inspect and validate user-submitted prompt templates in CI/CD pipelines before deployment to production agents.
  • Automated Tool Calling & Schema Generation: Generate OpenAI and Anthropic tool call input schemas dynamically at runtime without manually coding repetitive boilerplate.
  • Multi-Tenant Prompt Management: Index variable keys across thousands of organization prompts for search, audit, and variable auto-completion.

Native Usage

How to extract prompt variables locally in terminal environments:

Windows (PowerShell)

# Extract {{variable}} and ${variable} in PowerShell
$prompt = Get-Content -Raw -Path "prompt.txt"
[regex]::Matches($prompt, '\{\{\s*([^}]+)\s*\}|\$\{\s*([^}]+)\s*\}') | ForEach-Object { $_.Value }

Linux / Unix (Bash)

# Extract {{variable}} matches using grep
grep -oP '\{\{\s*\K[a-zA-Z_0-9\-]+(?=\s*\}\})' prompt.txt | sort -u

Python

Using Python standard library:

import re

prompt = "Hello {{user_name}}, welcome to ${company}! Your role is {role}."
pattern = r'\{\{\s*([a-zA-Z0-9_-]+)\s*\}\}|\$\{\s*([a-zA-Z0-9_-]+)\s*\}|(?<!\{)\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}(?!\})'

matches = re.findall(pattern, prompt)
variables = sorted(list(set(filter(None, [var for match in matches for var in match]))))
print("Extracted Variables:", variables)

Java

Using Java standard library:

import java.util.*;
import java.util.regex.*;

public class PromptExtractor {
    public static void main(String[] args) {
        String prompt = "Hello {{user_name}}, welcome to ${company}!";
        Pattern pattern = Pattern.compile("\\{\\{\\s*([a-zA-Z0-9_-]+)\\s*\\}\\}|\\$\\{\\s*([a-zA-Z0-9_-]+)\\s*\\}");
        Matcher matcher = pattern.matcher(prompt);
        Set<String> variables = new TreeSet<>();

        while (matcher.find()) {
            String v = matcher.group(1) != null ? matcher.group(1) : matcher.group(2);
            variables.add(v);
        }
        System.out.println("Variables: " + variables);
    }
}

Frequently Asked Questions (FAQ)

Which template variable formats are detected?

The extractor supports Mustache/Handlebars/Jinja ({{var}}), JS Template Literals (${var}), Python f-strings and LangChain ({var}), XML/Angle brackets (<var>), Windows Environment (%var%), and SQL/Route named parameters (:var).

How can I use the extracted variables in OpenAI Function Calling or Structured Outputs?

The tool automatically generates an exportable Draft 2020-12 JSON Schema matching all extracted variable names, ready to paste directly into OpenAI response_format or tool definitions.

Can I extract prompt variables programmatically via REST API?

Yes. The tool provides a high-speed REST API endpoint (POST https://blueutils.com/api/ai/extract-prompt-variables) for seamless CI/CD and automated prompt testing.

Does the extractor count variable duplicate occurrences and line positions?

Yes. The output report lists total occurrences, unique variable counts, and exact line/column coordinates for every placeholder reference across your prompt.

Are my confidential prompts or system instructions processed privately?

Yes. All variable parsing, regex matching, and schema generations run 100% client-side inside your browser session without sending prompt text to external servers.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.