The Complete Funscript Format Guide: Structure, Syntax & Best Practices

Master the funscript JSON format with this comprehensive guide. Learn about action arrays, at/pos values, metadata fields, validation rules, and common mistakes to avoid.

The funscript format is the universal standard for encoding haptic device movements synchronized to video content. Whether you are building tools, writing scripts by hand, or debugging AI-generated output, understanding the format at a structural level is essential. This guide covers every aspect of the .funscript file specification: the JSON schema, action arrays, metadata fields, validation rules, and the most common mistakes that trip up both beginners and experienced scripters.

What Is a Funscript File?

A funscript file is a plain JSON document with the .funscript extension. It describes a series of timed position commands for haptic devices such as strokers, vibrators, and multi-axis machines. Each command tells the device where to be (position 0-100) at a specific moment in time (milliseconds from the start of the video).

The format came out of the open-source community and has since become the de facto standard for haptic playback applications. Players like DeoVR, XBVR, ScriptPlayer, Heresphere, and platforms like HaptiQ all work with this format.

Because funscript is JSON, it is human-readable, machine-parseable, and trivially serializable. You can open a funscript file in any text editor, inspect its contents, and even hand-edit individual keyframes if needed. This openness is one of the format's greatest strengths.

Basic JSON Structure

At its core, a funscript file contains a single JSON object with an actions array and optional metadata fields. Here is the minimal valid funscript:

{
  "actions": [
    { "at": 0, "pos": 50 },
    { "at": 500, "pos": 100 },
    { "at": 1000, "pos": 0 },
    { "at": 1500, "pos": 100 },
    { "at": 2000, "pos": 50 }
  ]
}

This five-action script defines a simple up-down-up-down pattern over two seconds. The device starts at the midpoint (50), moves to the top (100) at 500ms, drops to the bottom (0) at 1000ms, returns to the top at 1500ms, and settles back to the midpoint at 2000ms.

The Actions Array: at and pos

The actions array is the heart of every funscript. Each element is an object with exactly two required properties:

Between two consecutive actions, the device interpolates linearly. If action A is {"at": 0, "pos": 0} and action B is {"at": 1000, "pos": 100}, the device will move smoothly from position 0 to position 100 over the course of one second. This linear interpolation is the fundamental movement model of the funscript format.

The density of actions determines the smoothness and complexity of the motion. A script with 2-4 actions per second of video produces simple, mechanical-feeling movements. Scripts with 8-12 actions per second capture more nuanced motion but produce larger files. Most well-crafted scripts average 4-8 actions per second.

Position Value Semantics

The 0-100 position range is abstract and device-agnostic. Different devices interpret this range differently based on their physical stroke length. The Handy has an approximate stroke length of 110mm, while the Kiiroo Keon has about 60mm. A position change from 0 to 100 on The Handy produces a larger physical movement than the same change on the Keon.

This abstraction is intentional: it lets the same funscript work across different devices without modification. The device firmware or driver handles the mapping from the 0-100 range to physical actuator positions.

Timestamp Precision

Timestamps are in milliseconds, which provides more than enough precision for haptic synchronization. Most devices cannot respond to commands faster than 10-20ms apart, so sub-millisecond precision is unnecessary. In practice, the limiting factor is always the device's mechanical response time, not the timestamp resolution.

Metadata Fields

Beyond the required actions array, funscript files can include optional metadata fields that provide context about the script. While no player requires these fields, they are useful for organization, attribution, and tool interoperability.

{
  "version": "1.0",
  "inverted": false,
  "range": 90,
  "info": "Example script",
  "metadata": {
    "creator": "HaptiQ Team",
    "description": "AI-generated script for demo video",
    "duration": 180000,
    "license": "CC BY-SA 4.0",
    "notes": "Post-processed with Savitzky-Golay smoothing",
    "performers": [],
    "script_url": "",
    "tags": ["ai-generated", "smooth"],
    "title": "Demo Script",
    "type": "basic",
    "video_url": ""
  },
  "actions": [...]
}

Here is what each metadata field means:

Field Type Description
versionstringFormat version, typically "1.0"
invertedbooleanIf true, players should flip position values (100 - pos)
rangeintegerMaximum range percentage (0-100) the script was designed for
infostringFree-text description of the script
metadata.creatorstringAuthor or tool that created the script
metadata.durationintegerTotal duration in milliseconds
metadata.typestring"basic" for single-axis, "multi" for multi-axis
metadata.tagsstring[]Searchable tags for categorization

Validation Rules

A structurally valid funscript must satisfy these constraints. HaptiQ's quality analyzer checks most of these for you.

  1. Valid JSON: The file must parse as valid JSON. Trailing commas, unquoted keys, single quotes, and comments are not permitted in standard JSON.
  2. Actions array exists: The root object must contain an actions key with an array value.
  3. Actions are not empty: The actions array must contain at least one action. An empty actions array is technically parseable but produces no device movement.
  4. Each action has at and pos: Every element in the actions array must have both at and pos as integer properties.
  5. at is non-negative: Timestamps must be zero or positive integers. Negative timestamps are invalid.
  6. pos is in range: Position values must be integers between 0 and 100 inclusive. Values outside this range may cause unpredictable device behavior.
  7. Actions are sorted: Actions should be sorted by ascending at value. While some players tolerate unsorted actions and sort them internally, this is not guaranteed.
  8. No duplicate timestamps: Two actions at the same at value create ambiguity. Different players resolve this differently, so it should be avoided.

File Naming Convention

Funscript files follow a naming convention that ties them to their associated video. The standard practice is to use the exact same filename as the video but with the .funscript extension:

my-video.mp4          -> my-video.funscript
vacation-clip.mkv     -> vacation-clip.funscript
vr-180-sbs.mp4        -> vr-180-sbs.funscript

Players like DeoVR, Heresphere, and XBVR automatically detect the matching funscript when both files are in the same directory. If the names do not match, you will need to manually associate the script with the video in the player's interface.

For multi-axis scripts (T-code), additional axes use a suffix notation: my-video.L0.funscript for the primary linear axis, my-video.R0.funscript for the primary rotation axis, and so on. This convention allows players to load all axes simultaneously.

Common Mistakes and How to Fix Them

These are the most frequent structural issues in funscripts:

1. Position Values Out of Range

Some tools output position values as floats (e.g., 67.5) or exceed the 0-100 range (e.g., 105 or -3). While some players handle this gracefully by clamping, others may crash or produce erratic device behavior. Always ensure pos values are integers between 0 and 100. HaptiQ's clamp plugin fixes this automatically.

2. Unsorted Actions

If you manually edit a funscript and insert or move keyframes, the actions array can end up out of order. Always sort by at value before saving. HaptiQ's structure check flags unsorted actions.

3. Excessive Keyframe Density

Scripts with 30+ actions per second of video are unnecessarily dense. The additional keyframes add file size without improving perceived quality because the device cannot physically respond to position changes faster than approximately every 20ms. Use the RDP simplification algorithm (available as a HaptiQ plugin) to reduce density while preserving the script's character.

4. Dead Zones

A dead zone is a stretch where the position does not change, so the device sits still. This often happens at the beginning or end of a script, or during scene transitions. HaptiQ's quality analyzer flags dead zones (position unchanged for more than 2 seconds) and suggests adding motion there.

5. Unrealistic Speeds

Two actions like {"at": 1000, "pos": 0} and {"at": 1050, "pos": 100} demand a full-range stroke in 50ms, which is faster than any device can physically achieve. The device falls behind the script and produces poor synchronization. HaptiQ's speed limiter plugin caps movement rates to device-realistic values.

6. Invalid JSON Syntax

Common JSON syntax errors include trailing commas after the last element in an array, missing commas between elements, and using JavaScript-style comments. Use a JSON validator or import into HaptiQ to catch these immediately.

File Size Considerations

Funscript files are typically small. A well-optimized script for a 30-minute video averages 50-150 KB. However, scripts generated by overly aggressive motion tracking or without simplification can balloon to 1-5 MB with tens of thousands of unnecessary keyframes.

Video Length Typical Actions Optimized Size Unoptimized Size
5 minutes1,500 - 3,00015 - 40 KB100 - 300 KB
15 minutes4,500 - 9,00050 - 120 KB300 KB - 1 MB
30 minutes9,000 - 18,000100 - 250 KB500 KB - 2 MB
60 minutes18,000 - 36,000200 - 500 KB1 - 5 MB

HaptiQ's RDP simplification plugin can substantially reduce file size while keeping the script's motion character intact.

Tools for Working with Funscript Files

Because funscript is JSON, any tool that handles JSON can work with funscript files. Here are the most useful approaches:

Advanced Patterns

Holding Patterns

To hold the device at a specific position, place two actions with the same pos value at different timestamps. For example, {"at": 5000, "pos": 50} followed by {"at": 8000, "pos": 50} keeps the device at position 50 for three seconds. This is useful during scene transitions or dialog-heavy moments.

Easing and Acceleration

The funscript format only supports linear interpolation between keyframes. To simulate easing (acceleration and deceleration), you insert additional keyframes that approximate a curve. For example, to create an ease-in motion from position 0 to 100 over one second, you might use: 0ms/0, 200ms/5, 400ms/20, 600ms/45, 800ms/75, 1000ms/100. The closely-spaced keyframes at the beginning create the illusion of gradual acceleration.

Vibration Patterns

A funscript has no intensity channel, so HaptiQ plays it on vibrating toys speed-mapped: the level follows how fast the script is moving. A fast full-range move is full power, a slow drift is a low level, and a held position is off.

How HaptiQ Handles Funscript Validation

When you import a funscript into HaptiQ, a file that is not valid JSON is rejected with an error, and the structure check reports issues such as unsorted actions, duplicate timestamps and out-of-range positions. The quality analyzer scores scripts on a 0-100 scale and provides specific, actionable suggestions for improvement. Fixes are available as plugins, such as clamp for out-of-range positions and RDP simplification for over-dense scripts.

Scripts generated by HaptiQ's pipeline come out as standard .funscript files you can check the same way.

Validate Your Funscripts Instantly

Import any .funscript file into HaptiQ and get an instant quality report with a 0-100 score and specific improvement suggestions.

Frequently asked questions

What is a .funscript file and how does it work?

A .funscript file is a plain JSON document that encodes timed position commands for haptic devices synchronized to video content. The file contains an actions array where each element has two integer fields: "at" (timestamp in milliseconds from the start of the video) and "pos" (target device position from 0 to 100, where 0 is the bottom of the stroke and 100 is the top). Between keyframes, devices interpolate linearly. So an action at t=0 with pos=0 followed by an action at t=1000 with pos=100 produces a smooth full-range stroke over one second. Because funscript is standard JSON, you can open it in any text editor, parse it with any language, or validate it with HaptiQ's quality analyzer, which scores scripts 0–100 and flags structural issues automatically.

What fields are required in a valid funscript file?

Only one field is strictly required: the top-level "actions" array, containing at least one action object. Each action must have both "at" (non-negative integer milliseconds) and "pos" (integer 0–100). Everything else is optional metadata: "version" (typically "1.0"), "inverted" (boolean, flips positions 100-pos when true), "range" (designed-for percentage), "info" (free-text description), and a nested "metadata" object with fields like creator, duration, type, tags, license, and performers. Players like DeoVR, Heresphere, XBVR, and ScriptPlayer read the actions array regardless of what metadata is present, so a minimal two-line file with just {"actions": [...]} is valid and playable. Rich metadata is recommended for organization and attribution but never required.

How many actions per second should a good funscript have?

Well-crafted funscripts average 4 to 8 actions per second of video, which produces smooth, nuanced motion without bloating the file. Scripts with fewer than 2 actions per second feel mechanical and miss subtle movements. Scripts with more than 20 actions per second are generally wasteful because most haptic devices cannot physically respond to commands faster than every 20ms — the extra keyframes add file size without improving the experience. If you have a legacy script that is too dense, the RDP (Ramer-Douglas-Peucker) simplification plugin can substantially reduce keyframe count while preserving the script's motion character.

Can I open and edit a .funscript file in a text editor?

Absolutely. Because funscript is standard JSON, any text editor with JSON syntax highlighting — VS Code, Sublime Text, Notepad++, vim, emacs — can open and edit it. You can change individual timestamps, adjust position values, rearrange keyframes, or add metadata by hand. Just keep three rules in mind: keep the JSON syntactically valid (no trailing commas, proper quoting), keep positions as integers between 0 and 100 inclusive, and keep actions sorted by ascending "at" value. If you make a JSON mistake, HaptiQ rejects the file on import with an error, so you know to fix it. For anything beyond small tweaks, a dedicated editor like HaptiQ's interactive timeline or OpenFunscripter is faster and safer than raw text editing.

What is the difference between single-axis and multi-axis funscripts?

Single-axis funscripts (the common case, labeled "basic" in metadata.type) describe motion for one degree of freedom — typically linear stroke. Multi-axis funscripts describe motion across multiple independent axes simultaneously for devices like the OSR2+ and SR6. The standard multi-axis convention uses separate .funscript files per axis with suffix notation: video.L0.funscript for the primary linear axis, video.R0.funscript for primary rotation, video.L1 and L2 for secondary linear axes, R1/R2 for pitch/roll, V0 for vibration, and A0 for auxiliary. HaptiQ supports all 8 standard axes (L0–L2, R0–R2, V0, A0) and can export T-code directly for hardware that uses the T-code protocol. Multi-axis scripts typically live in the same directory as the video, and players load all matching files automatically.

How do I validate a .funscript file and fix common errors?

HaptiQ rejects files that are not valid JSON on import, and its structure check covers an empty actions array, missing "at" or "pos" fields, positions outside 0–100, negative timestamps, unsorted actions and duplicate timestamps, reporting the action index for ordering and duplicate issues. The most common errors are position values as floats or out of range (fixed by the clamp plugin), unsorted actions (flagged by the structure check), excessive keyframe density over 30/sec (fixed by RDP simplification), dead zones where the position does not change for more than 2 seconds (flagged by the quality analyzer), and unrealistic speeds exceeding device limits (fixed by the speed-limiter plugin). HaptiQ's quality analyzer also produces a 0–100 score with specific improvement suggestions.

Create a free HaptiQ account to generate a funscript from your own video.