VTL Template Tester - Offline Velocity Template Language Evaluator for API Gateway and AppSync

First Published:
Last Updated:

Test AWS API Gateway mapping templates and AppSync resolver templates locally in your browser. Evaluate a VTL source against editable context JSON, expand $util helpers, and see the rendered payload instantly - no AWS console, no credentials, no round-trips.

All processing is performed entirely in your browser using client-side JavaScript. No data is transmitted to any server. Your templates and context payloads never leave your device.

  • This tool is provided "AS IS" without any warranties of any kind.
  • It implements a pragmatic subset of Apache Velocity and the AWS $util namespace - not a byte-for-byte replica of AWS behavior.
  • The author accepts no responsibility for incorrect routing, data mutation, or errors caused by relying on its output.
  • Always validate critical mapping templates and resolvers in AWS (API Gateway test invoke / AppSync query console) before deploying to production.
  • By using this tool, you accept full responsibility for any outcomes.

This tool uses client-side JavaScript for all processing. No data is transmitted to servers, no files are uploaded online, all processing happens locally in your browser. Once loaded, this tool continues to work even without an internet connection. For more details, please refer to our Web Tools Disclaimer.

Loads a ready-made template and matching context JSON.
Paste your API Gateway mapping template or AppSync resolver (request or response).
Context variables exposed to the template ($input, $context, $ctx, $stageVariables, ...).

    
Supported subset
  • References: $var, ${var}, $!var, $obj.field, $arr[0], $obj.method(arg)
  • Directives: #set, #if / #elseif / #else / #end, #foreach(...) ... #end, #break, #stop, ## and #* ... *# comments
  • Operators: == != < > <= >= && || ! + - * / % (word aliases: eq ne lt gt le ge and or not)
  • Literals: strings (double-quoted strings interpolate references), numbers, booleans, null, array [1,2,3], range [1..5], map {"a":1}
  • $util (AppSync / API Gateway): toJson, parseJson, qr / quiet, escapeJavaScript, urlEncode / urlDecode, base64Encode / base64Decode, error, appendError, isNull, isNullOrEmpty, isNullOrBlank, defaultIfNull, defaultIfNullOrEmpty, autoId, dynamodb.toMap / toMapValues / toDynamoDB / toString / toNumber / toBoolean / toStringSet / toNumberSet / toList
  • API Gateway only: when $input.body is a JSON string, $input.path("$.x.y") and $input.json("$.x") are synthesized automatically.

Features

  • API Gateway and AppSync modes: Switch context presets between $input/$context (API Gateway mapping template) and $ctx.args/$ctx.identity (AppSync resolver).
  • Instant rendering: Evaluate your VTL against an editable JSON context and see the rendered payload - faster than deploying to AWS just to test a template tweak.
  • $util helpers: $util.toJson, $util.escapeJavaScript, $util.urlEncode, $util.dynamodb.toMapValues, $util.error, and more are implemented in JavaScript.
  • Presets: One-click examples for API Gateway body-to-DynamoDB PutItem, AppSync Query and PutItem, and validation error patterns using $util.error.
  • Pretty-print JSON: Optionally format the rendered output as pretty JSON when it parses successfully.
  • Privacy: Everything runs locally in your browser. No templates, context, or rendered output is sent anywhere.

How to Use

  1. Choose API Gateway or AppSync mode based on the template you are testing.
  2. Pick a preset from the dropdown to load a working example, or paste your own template in the left editor.
  3. Edit the Context JSON on the right to reflect the request you want to simulate (request body, arguments, identity claims, stage variables, etc.).
  4. Click Render Template. The rendered output appears below; success/warning/error messages show in the banner.
  5. Toggle Pretty-print JSON output to format structured output, and use Copy Output to copy the result to the clipboard.

Important Notes

  • Subset only: This tester implements a pragmatic subset of Apache Velocity (no macros, no #parse/#include, no custom Velocity tools) and a subset of the AWS $util namespace. Uncommon edge cases may diverge from AWS behavior.
  • Not a replacement for AWS testing: Always validate templates in API Gateway's "Test" invocation feature or the AppSync console query editor before relying on them in production.
  • $util.error: Calling $util.error(...) aborts rendering just like on AWS. Everything emitted so far is preserved and the abort reason is surfaced as a warning message.
  • $input.path / $input.json (API Gateway): When the provided context has $input.body as a JSON string, the tool synthesizes $input.path("$...") and $input.json("$...") from the parsed JSON using a simplified JSONPath resolver. Complex JSONPath filters ($..foo, predicates) are out of scope.
  • AppSync JavaScript Resolvers: Those are a different execution model (not VTL) and are not supported here.
  • Error location: Parse errors include the line and column from the original template source to help pinpoint the offending construct.

References:
Tech Blog with curated related content
Web Tools Collection

Written by Hidekazu Konishi