For the complete documentation index, see llms.txt. This page is also available as Markdown.

type

Returns the JavaScript type of a value as a string. Useful for debugging and conditional logic based on data types.

{% assign t = my_var | type %}
{% log t %}

Syntax

{{ value | type }}
Parameter
Description

value

Any value to check the type of

Return Value

Returns a string — one of: "string", "number", "boolean", "object", "undefined".

Examples

Check the type of a variable:

{% assign t = product.price | type %}
{% log "Price type: " | append: t %}

Output:

Price type: string

Conditional logic based on type:

{% assign t = input_value | type %}
{% if t == "string" %}
  {% assign parsed = input_value | parse_json %}
{% elsif t == "object" %}
  {% assign parsed = input_value %}
{% endif %}
{% log parsed %}

Debug unknown data:

Validate function parameters:

Notes

  • Returns JavaScript typeof values: "string", "number", "boolean", "object", "undefined"

  • Arrays return "object" — use the size filter to check if a value is array-like

  • null returns "object" (standard JavaScript behavior)

  • Useful for debugging when you're unsure what type a variable holds

Last updated