Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors

TBEL Overview

ThingsBoard Expression Language (TBEL) is a lightweight scripting language purpose-built for IoT data transformation. It is a fork of MVEL with additional security constraints and built-in memory management.

TBEL is the default scripting engine for Script calculated fields, rule engine filter and transformation nodes, and other server-side scripting contexts.

Prior to TBEL, ThingsBoard used Nashorn (the JDK-bundled JavaScript engine) for server-side scripting. Nashorn was deprecated in JDK 11 and removed in JDK 15 — leaving two alternatives:

  • GraalVM JavaScript — excellent but carries a heavy runtime footprint and licensing constraints that make it impractical for most self-hosted deployments.
  • Remote JS Executors — Node.js processes that receive scripts over the message queue. They work, but add inter-process communication latency and consume extra system resources.

TBEL was created to provide a fast, secure, zero-dependency scripting option that runs inside the JVM without external processes.

TBEL delivers roughly 1 000× better performance for typical transformation scripts.

Metric Nashorn TBEL
1 000 iterations of return msg.temperature > 20 ~16 000 ms ~12 ms
Startup cost per script High (JIT compilation) Negligible
Memory isolation Weak Strong (per-execution memory limit)
Security sandbox Manual, error-prone Built-in (restricted class access)
Aspect Remote JS Executors TBEL
Additional process Yes (Node.js) No
Network/queue overhead Yes No
Language Full ES6+ JavaScript MVEL-based (Java-like)
Use case Complex scripts that need full JS ecosystem Typical IoT transformations

Each TBEL script call runs within limits, so that one script can’t slow down or exhaust the server. The limits apply wherever TBEL runs: rule nodes, data converters, and calculated fields.

Limit Default Environment variable Error message
Input size 100,000 characters TBEL_MAX_TOTAL_ARGS_SIZE Script input arguments exceed maximum allowed total args size of 100000 symbols
Result size 300,000 characters TBEL_MAX_RESULT_SIZE Script invocation result exceeds maximum allowed size of 300000 symbols
Memory per call 8 MB TBEL_MAX_MEMORY_LIMIT_MB Script memory overflow!
Time per call 500 ms TBEL_MAX_REQUEST_TIMEOUT Script timeout!

The script itself can be up to 50,000 characters long (TBEL_MAX_SCRIPT_BODY_SIZE).

These defaults apply to the ThingsBoard server and the integration executor. A remote integration has its own defaults: 300,000 characters for the input, 16 MB of memory, and 100,000 characters for the script.

The size errors show the limit that is in effect. The result is measured as the length of its JSON form.

How the input size is counted. The input is everything the script receives, measured as text. A string counts by its length, and any other value by the length of its JSON form:

  • Data converter: The payload is a byte array and counts as its Base64 text, about 4/3 of the payload size, plus the metadata as JSON.
  • Rule node: The input is the message, its metadata, and the message type.
  • Calculated field: The arguments count by their estimated size in memory.

With the default 100,000-character limit, a data converter accepts payloads of a little less than 75,000 bytes.

A call that exceeds the input size, result size, memory, or time limit counts as an error for that script. Errors in the script’s own logic, like calling a method on a null value, don’t count.

When a script reaches three errors (TBEL_MAX_ERRORS), each within 60 seconds (TBEL_MAX_BLACKLIST_DURATION_SEC) of the previous one, ThingsBoard blocks it. Every call then fails immediately with Script invocation is blocked due to maximum error count 3, scriptId <id>!, including calls with valid input.

A few oversized or slow messages therefore stop the regular ones too:

  • A rule node sends every message to its Failure connection.
  • A data converter fails every message, and its data isn’t stored.

The block ends 60 seconds after the last counted error. Saving a change to the converter or rule node, or restarting the service, clears it right away. Each server keeps its own count, so in a cluster a script can be blocked on one server and still run on another.

Set the limits on every service that runs the script, then restart it. An integration executor and a remote integration have their own configuration. See How to change configuration, and the TBEL parameters in the Core and Rule Engine and Integration Executor configuration references.

  • Set TBEL_MAX_TOTAL_ARGS_SIZE above your largest input. For a data converter, that’s about 4/3 of the largest payload in bytes, plus the metadata.
  • Raise TBEL_MAX_RESULT_SIZE, TBEL_MAX_MEMORY_LIMIT_MB, and TBEL_MAX_REQUEST_TIMEOUT along with it. The decoded result can be larger than the payload it came from, so a message that passes the input check can still fail on result size, memory, or time.
  • If oversized messages are rare but expected, raise TBEL_MAX_ERRORS or lower TBEL_MAX_BLACKLIST_DURATION_SEC. Each such message then fails on its own instead of blocking the script. The same settings decide how quickly a script that keeps timing out is stopped, so a slow script can hold the thread pool for longer.
  • Larger limits cost more CPU and memory per call. All TBEL scripts on a server, including rule nodes, share one thread pool (TBEL_THREAD_POOL_SIZE), so long calls on large inputs can delay other scripts. The wait counts toward their time limit, so a delayed script can time out and be blocked too.
  • You can also split large batches into smaller messages before sending them to ThingsBoard.

Date formatting changes in ThingsBoard 4.4+

Section titled “Date formatting changes in ThingsBoard 4.4+”

ThingsBoard 4.4 runs on Java 25; 4.3 and earlier required Java 17 or higher. The JDK bundles the Unicode CLDR locale database, and the CLDR data shipped with Java 21 changed the way a number of locales render dates and times. Because 4.4 jumps straight from Java 17 to Java 25, every deployment that upgrades inherits all of those changes at once. If you already run Java 21 — the release the 4.3 install guides recommended — these strings are what you see today, and nothing changes for you.

TBEL itself did not change — the Date methods simply return what the newer JDK formats. Scripts that treat a locale-formatted date as a stable string can therefore start behaving differently after the upgrade.

Method (locale) ThingsBoard 4.3 (Java 17) ThingsBoard 4.4+ (Java 25) What is different
toLocaleTimeString (en-US) 9:04:05 PM 9:04:05 PM The separator before AM/PM is a narrow no-break space (U+202F) instead of an ordinary space (U+0020). Nothing looks different.
toLocaleString, full date and time (en-US) Tuesday, September 5, 2023 at 9:04:05 PM Eastern Daylight Time Tuesday, September 5, 2023, 9:04:05 PM Eastern Daylight Time The literal at is replaced by a comma, and PM is again preceded by U+202F.
toLocaleDateString, full date (uk-UA) середа, 6 вересня 2023 р. середа, 6 вересня 2023 р. The space before р. is a narrow no-break space (U+202F). Nothing looks different.
toLocaleString, full date and time (uk-UA) середа, 6 вересня 2023 р. о 04:04:05 за східноєвропейським літнім часом середа, 6 вересня 2023 р., 04:04:05 за східноєвропейським літнім часом The literal о is replaced by a comma, and р. is preceded by U+202F.
toLocaleString (ar-EG) 5/9/2023, 9:04:05 م 5/9/2023، 9:04:05 م The ASCII comma becomes the Arabic comma (U+060C). In the full date and time form, the connector في is likewise replaced by ،.
toTimeString, locale UTC or GMT, zone Europe/Kyiv 04:04:05 Eastern European Summer Time 04:04:05 Kyiv (+1) UTC and GMT are not language tags, so the first argument falls back to the root locale. There the descriptive zone name becomes a city name plus the daylight-saving indicator — (+1) while summer time is in effect, (+0) otherwise. It is not the UTC offset: America/New_York also reports New York (+1) for this instant. Passing a real locale such as en-US or uk-UA keeps the descriptive name.
var d = new Date(1693962245000);
var time = d.toLocaleTimeString("en-US", "America/New_York");
// 4.3: "9:04:05 PM" - ordinary space before PM
// 4.4: "9:04:05 PM" - narrow no-break space (U+202F) before PM
time.endsWith(" PM"); // 4.3: true; 4.4: false
time.split(" ")[1]; // 4.3: "PM"; 4.4: fails, there is no ordinary space to split on
var options = '{"timeZone":"America/New_York","dateStyle":"full","timeStyle":"full"}';
var full = d.toLocaleString("en-US", options);
// 4.3: "Tuesday, September 5, 2023 at 9:04:05 PM Eastern Daylight Time"
// 4.4: "Tuesday, September 5, 2023, 9:04:05 PM Eastern Daylight Time"
full.split(" at ")[0]; // 4.3: "Tuesday, September 5, 2023"; 4.4: the whole string, " at " is gone
  • Store and compare dates in ISO 8601. toISOString() and toJSON() follow the ISO standard rather than locale data, so their output is byte-for-byte identical on Java 17 and Java 25.
  • Ask for an explicit pattern whenever the layout matters. A pattern in the options string is applied literally, so separators and the AM/PM marker no longer depend on CLDR. Localized names produced by pattern letters such as MMMM or EEEE still come from the JDK.
  • Compare numbers, not formatted text. Use the numeric getters instead of matching "PM", " at " or a localized month name.
var d = new Date(1693962245000);
d.toISOString(); // "2023-09-06T01:04:05Z" - identical on 4.3 and 4.4
d.toLocaleString("en-US", '{"timeZone":"America/New_York","pattern":"yyyy-MM-dd hh:mm:ss a"}');
d.getUTCHours() >= 12; // numeric check instead of matching "PM"
Methods Status
toLocaleString, toLocaleDateString, toLocaleTimeString, toString, toDateString, toTimeString, toUTCString Affected — the output comes from locale data
toISOString, toJSON, getTime, valueOf, all numeric getters, and any call that supplies an explicit pattern Unaffected — the output does not depend on locale data. An explicit pattern still renders localized names for letters such as MMMM and EEEE.
  • Language Guide — syntax, data types, collections, and control flow.
  • Helper Functions — encoding, byte parsing, hex conversion, date/time, geofencing, and more.