Jinja2 Template Tester

Home Assistant’s built-in template editor requires you to be logged in, and every test requires a round-trip to your live system. If you are iterating on a complex template, that adds up fast. This tool lets you write and test Jinja2 templates entirely in your browser, against mocked entity states you define yourself, without touching HA at all.

It is useful for building conditional messages, formatting sensor values, writing template conditions for automations, and debugging template logic before it goes anywhere near your running system.

Test Your Template

Write your Jinja2 template in the left panel. Define your mock entity states as JSON in the right panel. Click Render to see the output. Iterate until it looks right, then copy it into Home Assistant.

Jinja2 Template Tester

Test Home Assistant Jinja2 templates without logging in to HA

Free
Renders using Nunjucks — a JavaScript port of Jinja2. Supports HA functions including states(), state_attr(), is_state(), now(), and more. Define mock state values in the JSON panel on the right.

How to Write Mock Variables

The mock variables panel accepts JSON. Define entity states and attributes to simulate what your real HA system would return. Here is a basic example:

{
  "states": {
    "sensor.outdoor_temperature": "18.5",
    "binary_sensor.front_door": "off",
    "person.yourname": "home"
  },
  "attributes": {
    "sensor.outdoor_temperature": {
      "unit_of_measurement": "°C",
      "friendly_name": "Outdoor Temperature"
    }
  }
}

You only need to define the entities your template actually references. Everything else can be omitted.

Supported Functions

These HA-compatible template functions are available in this tester.

FunctionWhat it does
states('entity_id')Returns the current state of an entity as a string
state_attr('entity_id', 'attribute')Returns a specific attribute of an entity
is_state('entity_id', 'value')Returns true if the entity state matches the given value
is_state_attr('entity_id', 'attr', 'value')Returns true if the attribute matches the given value
now()Returns the current local datetime
utcnow()Returns the current UTC datetime
as_timestamp(value)Converts a datetime string to a Unix timestamp
timedelta(hours=X, minutes=X)Creates a time delta for date arithmetic
int(value)Converts a value to an integer
float(value)Converts a value to a float
lower(value)Converts a string to lowercase
upper(value)Converts a string to uppercase

Example Templates

Paste these into the template panel to try the tester out.

Is anyone home?

{% if is_state('person.yourname', 'home') %}
  Someone is home.
{% else %}
  Nobody is home.
{% endif %}

Mock JSON: { "states": { "person.yourname": "home" } }

Format current time as a friendly string

It is {{ now().strftime('%I:%M %p') }} on {{ now().strftime('%A, %B %d') }}.

No mock variables needed.

Conditional message based on temperature

{% set temp = states('sensor.outdoor_temperature') | float %}
{% if temp < 0 %}
  It is below freezing outside.
{% elif temp < 10 %}
  It is cold outside.
{% else %}
  Temperature is {{ temp }}°C.
{% endif %}

Mock JSON: { "states": { "sensor.outdoor_temperature": "-3.2" } }

Nunjucks note: This tester runs on Nunjucks, which is approximately 99% compatible with Home Assistant’s Jinja2 implementation. The vast majority of HA templates will render identically. If a template renders here but behaves differently in HA, the Developer Tools template editor inside HA is the authoritative environment.

Found this useful? This tool is free and always will be. If it helped you debug a template faster, consider supporting the network.

Support the Network →