# behaviortrees.com > A free, open source online visual editor for behavior trees, used for game AI and robotics, plus practical guides to behavior trees. No account needed: projects save in the browser, with optional sign-in to sync them. The editor imports and exports behavior3 JSON, including custom node definitions, and BehaviorTree.CPP XML (v3 and v4, as used by Groot2 and ROS 2 Nav2). It runs entirely in the browser; there is no public API. ## Editor - [Behavior Tree Editor](https://www.behaviortrees.com/): what the editor does, with a live example - [Open the editor](https://www.behaviortrees.com/editor): create a project and start editing (requires JavaScript) - [Pricing](https://www.behaviortrees.com/pricing): the editor is free; paid custom integrations are available - [Changelog](https://www.behaviortrees.com/changelog): recent changes - [Source code](https://github.com/behaviortrees/behaviortrees): AGPL-3.0, issues and contributions welcome ## Example trees Each link opens the tree in the editor. The behavior3 JSON is at the linked .json URL. - [Cooldown-Gated Special Attacks](https://www.behaviortrees.com/?example=cooldown-specials): Attack selection with a priority selector: a dramatic rocket attack gated by a cooldown decorator, falling back to shooting while ammo lasts, then melee. Note the cooldown wraps the whole rocket sequence, not just the range check. JSON: https://www.behaviortrees.com/examples/cooldown-specials.json - [Enemy Patrol AI](https://www.behaviortrees.com/?example=enemy-patrol): A classic enemy NPC: attack the player when in range, chase when visible, otherwise patrol between waypoints. JSON: https://www.behaviortrees.com/examples/enemy-patrol.json - [Open The Door (Selector vs Sequence)](https://www.behaviortrees.com/?example=open-the-door): The classic teaching example: a selector tries strategies in priority order, and each strategy is a sequence of steps that must all succeed. JSON: https://www.behaviortrees.com/examples/open-the-door.json - [Robot Navigation With Recovery](https://www.behaviortrees.com/?example=robot-navigate-recovery): A Nav2-style navigate-to-pose tree: plan a path (with retries) and follow it; when navigation fails, run recovery behaviors in escalating fallback order — clear costmaps, spin, back up, wait — then retry navigation. JSON: https://www.behaviortrees.com/examples/robot-navigate-recovery.json - [Robot Pick And Place](https://www.behaviortrees.com/?example=robot-pick-and-place): A robotics-style task: acquire an object if not already holding one, carry it to the target, and place it. Grasping retries until it succeeds. JSON: https://www.behaviortrees.com/examples/robot-pick-and-place.json - [Survival Override Enemy](https://www.behaviortrees.com/?example=survival-override): A full enemy brain with a top-priority survival branch: when health runs low the agent abandons whatever it was doing to flee, heal, or fight cornered — no transitions required. JSON: https://www.behaviortrees.com/examples/survival-override.json ## MCP server and CLI - MCP server (Streamable HTTP, public, no auth): https://www.behaviortrees.com/mcp. Tools: validate_tree, create_editor_link, convert_tree, list_node_types, get_example, read_guide. Typical flow: write a behavior3 tree, validate_tree, fix errors, then create_editor_link and give the user the link. - Local MCP server over stdio: `npx -y behaviortrees mcp` - CLI: `npx behaviortrees validate tree.json`, `npx behaviortrees convert tree.json --to btcpp-v4`, `npx behaviortrees link tree.json`. Reads behavior3 JSON or BehaviorTree.CPP XML; `--json` for machine-readable output. - [npm package and docs](https://www.npmjs.com/package/behaviortrees) ## Open a tree in the editor from a link To give someone a behavior tree they can see and edit, link to https://www.behaviortrees.com/editor#tree= (the create_editor_link tool and `behaviortrees link` build these for you). It opens in a "Shared trees" project in their browser, with no account needed. The payload stays in the URL fragment, so it is never sent to the server. The payload is a behavior3 JSON tree (or a whole project file), in one of two encodings: - URL-encoded JSON (encodeURIComponent). Good for small trees written by hand. - base64url, without padding, of the zlib-compressed JSON. Use this for anything larger. Python: `base64.urlsafe_b64encode(zlib.compress(json.dumps(tree).encode())).rstrip(b"=").decode()`. Node: `zlib.deflateSync(JSON.stringify(tree)).toString("base64url")`. A minimal tree. Node positions are optional: a tree without a "display" field is laid out automatically. Composites list their "children" in order, decorators have one "child", and the rest are leaves. ```json { "title": "Guard", "root": "a", "nodes": { "a": { "name": "Priority", "children": [ "b", "c" ] }, "b": { "name": "Sequence", "children": [ "d", "e" ] }, "c": { "name": "Patrol" }, "d": { "name": "IsEnemyVisible" }, "e": { "name": "Attack" } }, "custom_nodes": [ { "name": "IsEnemyVisible", "category": "condition" }, { "name": "Attack", "category": "action" }, { "name": "Patrol", "category": "action" } ] } ``` As a link: https://www.behaviortrees.com/editor#tree=%7B%22title%22%3A%22Guard%22%2C%22root%22%3A%22a%22%2C%22nodes%22%3A%7B%22a%22%3A%7B%22name%22%3A%22Priority%22%2C%22children%22%3A%5B%22b%22%2C%22c%22%5D%7D%2C%22b%22%3A%7B%22name%22%3A%22Sequence%22%2C%22children%22%3A%5B%22d%22%2C%22e%22%5D%7D%2C%22c%22%3A%7B%22name%22%3A%22Patrol%22%7D%2C%22d%22%3A%7B%22name%22%3A%22IsEnemyVisible%22%7D%2C%22e%22%3A%7B%22name%22%3A%22Attack%22%7D%7D%2C%22custom_nodes%22%3A%5B%7B%22name%22%3A%22IsEnemyVisible%22%2C%22category%22%3A%22condition%22%7D%2C%7B%22name%22%3A%22Attack%22%2C%22category%22%3A%22action%22%7D%2C%7B%22name%22%3A%22Patrol%22%2C%22category%22%3A%22action%22%7D%5D%7D Built-in nodes: composites Sequence, Priority (a selector, also called fallback), MemSequence and MemPriority; decorators Inverter, Repeater, RepeatUntilFailure, RepeatUntilSuccess, MaxTime and Limiter; leaves Succeeder, Failer, Runner, Error and Wait. Declare any other node in "custom_nodes" with a category of action, condition, composite or decorator, plus optional "title", "description" and "properties". ## Guides: Foundations - [What Is a Behavior Tree? A Practical Introduction for Game AI](https://www.behaviortrees.com/learn/what-is-a-behavior-tree.md): Behavior trees explained from scratch: what they are, how ticks, sequences, selectors and decorators work, why games and robots use them, and an interactive editor to try one yourself. - [Sequence, Selector, and Decorator Nodes Explained](https://www.behaviortrees.com/learn/behavior-tree-nodes-explained.md): A complete reference to behavior tree node types — sequences, selectors, parallels, memory variants, decorators, conditions and actions — with worked examples you can open in a free online editor. - [Behavior Tree Blackboards: How Nodes Share Data](https://www.behaviortrees.com/learn/behavior-tree-blackboard.md): What a blackboard is, why every serious behavior tree framework has one, how key scoping works, and the patterns — and pitfalls — of using blackboards in Unreal, BehaviorTree.CPP, and behavior3. - [Behavior Trees vs Finite State Machines: Which Should You Use?](https://www.behaviortrees.com/learn/behavior-trees-vs-state-machines.md): An honest comparison of behavior trees and finite state machines for game AI — scalability, reactivity, debugging, performance — with concrete guidance on when each one wins. ## Guides: Tools & platforms - [Best Behavior Tree Tools by Engine (2026): Unity, Unreal, Godot, ROS 2, Python](https://www.behaviortrees.com/learn/best-behavior-tree-tools.md): The best behavior tree tools for Unity, Unreal Engine, Godot, ROS 2, and Python, compared on price, visual editing, live debugging, blackboards, and how actively they're maintained, with a recommended pick for each. - [Unity Behavior Trees Compared: Free and Paid Options (2026)](https://www.behaviortrees.com/learn/behavior-trees-in-unity.md): Unity Behavior, Behavior Designer, NodeCanvas or open source? What each costs, where each falls short, and how to choose before you're locked in. - [UE5 Behavior Trees Explained: Tasks, Decorators, Services](https://www.behaviortrees.com/learn/behavior-trees-in-unreal-engine.md): How Unreal's behavior trees, blackboards, tasks, decorators and services fit together, how UE differs from classic BTs, and a working patrol/chase tree. - [Behavior Trees in Godot: LimboAI, Beehave, and Rolling Your Own](https://www.behaviortrees.com/learn/behavior-trees-in-godot.md): Godot doesn't ship behavior trees, but the ecosystem has strong free options — LimboAI, Beehave, or a small GDScript implementation of your own — compared honestly, with a design-first workflow. - [Behavior Trees in Robotics: BehaviorTree.CPP, ROS 2, and Nav2](https://www.behaviortrees.com/learn/behavior-trees-in-robotics.md): Why robotics adopted behavior trees from games — and how BehaviorTree.CPP, ROS 2, and the Nav2 navigation stack use them today, with the key differences from game-style trees. - [Behavior Trees in Python: py_trees Tutorial and ROS 2 Guide](https://www.behaviortrees.com/learn/behavior-trees-in-python.md): Build a behavior tree in Python with py_trees: runnable code, blackboards, live tree output, a 40-line version from scratch, and py_trees_ros for ROS 2. ## Guides: Practice & production - [Behavior Tree Examples: 5 Common Game AI Patterns](https://www.behaviortrees.com/learn/behavior-tree-examples.md): Worked behavior tree examples you can open in a free online editor: patrol/chase/attack enemies, guard posts, fleeing at low health, retry loops, and cooldown-gated special attacks. - [Debugging Behavior Trees: The 6 Classic Mistakes](https://www.behaviortrees.com/learn/debugging-behavior-trees.md): Why your sequence restarts every tick, why the tree won't switch branches, why the agent flip-flops between two behaviors — the recurring behavior tree bugs, their causes, and how to fix each one. - [How to Write a Behavior Tree from Scratch (~100 Lines)](https://www.behaviortrees.com/learn/how-to-implement-a-behavior-tree.md): Implement a working behavior tree runtime yourself: the status enum, sequence, selector, memory variants, and decorators in about 100 lines of TypeScript that port directly to C#, GDScript, or C++. - [Structuring Large Behavior Trees: Subtrees, Reuse, and Scale](https://www.behaviortrees.com/learn/structuring-large-behavior-trees.md): How to keep behavior trees readable past 30 nodes — priority layering, extracting subtrees, parameterized leaves, naming conventions, and knowing when logic shouldn't live in the tree at all. ## Optional - [Classic editor](https://old.behaviortrees.com): the original behavior3 editor (AngularJS)