Formulas reference

Browse the built-in formulas in toddle. You can use the built-in formulas to build complex logic in your web app that wrangles the data you 

Absolute

Get the absolute value of a Number.

Input

  • ValueNumber

    The input Number.

OutputNumber

The absolute value of the input.

Add

Get the sum of multiple numbers.

Input

  • 0Number

    Number to be added.

  • 1Number

    Number to be added.

OutputNumber

The sum of all the input numbers.

Append

Add an element to the end of an Array.

Input

  • ArrayArray

    The Array to append to.

  • ItemAny

    The item to append to the Array.

OutputArray

A new Array containing all elements from the input Array, including the new item.

Boolean

Convert a value of any type to a Boolean.

Input

  • InputAny

    Value of any type.

OutputBoolean

The input value converted to a Boolean. False and Null will return False, all other values will return True.

Branch Name

Get the name of the current branch. For production, the branch name is 'main'.

Input

    OutputString

    Returns the name of the current branch.

    Can Share

    Return a Boolean indicating whether the provided data can be shared (with the "Share" action).

    Input

    • URLString

      The URL you want to check.

    • TitleString

      The title you want to check.

    • TextString

      The text you want to check.

    Output

    null

    Capitalize

    Capitalize a string: make the first letter uppercase whilst keeping the rest lowercase.

    Input

    • StringString

      An input String.

    OutputString

    The capitalized String.

    Clamp

    Limit a value to a specified Min and Max value.

    Input

    • ValueNumber

      Number to round.

    • MinNumber

      The smallest allowed Number.

    • MaxNumber

      The largest allowed Number.

    OutputNumber

    Returns the input value if between the specified Min and Max. Otherwise, it returns the Min or Max value.

    Concatenate

    Concatenate two or more values.

    Input

    • 0Array \| String

      undefined

    OutputArray \| String

    Returns a String or Array containing all the specified input values.

    Current URL

    Return the current URL of the browser. Use the "Parse URL" formula for working with the URL.

    Input

      OutputString

      The browser's current URL.

      Date From String

      Convert a string to a Date.

      Input

      • Date stringString

        A String representing a date, for example "January 1, 1970".

      OutputDate

      The input value converted to a Date.

      Date From Timestamp

      Convert a timestamp (milliseconds) to a Date.

      Input

      • TimestampNumber

        A Number in milliseconds since 1st January, 1970 (EPOCH).

      OutputDate

      The input value converted to a Date.

      Decode URI Component

      Decode a URI component that was previously encoded with the Encode URI Component formula.

      Input

      • EncodedURIString

        The encoded URI to decode.

      OutputString

      The decoded URI component.

      Decode base64

      Deocde a base64 string to utf-8.

      Input

      • Base64 valueString

        The input data encoded as base64.

      OutputString

      The decoded string.

      Default to

      Return the first value that is not False or Null.

      Input

      • 0Any

        The inital value.

      • 1Any

        The first fallback value to be used if the primary value is Null or False.

      OutputAny

      Returns the first value that is not False or Null. Returns Null if no valid values is given.

      Delete

      Return a copy of the input Object or Array without the specified key.

      Input

      • ObjectArray \| Object

        The input record.

      • PathArray<Number \| String> \| Number \| String

        The path can be either a Number (if the first argument is an array), a String, or an Array of strings. If an Array is given, the property at that path will be removed.

      OutputObject

      A copy of the record without the property specified in the Path.

      Divide

      Perform a division calculation.

      Input

      • DividendNumber

        The number to be divided.

      • DivisorNumber

        The number to divide by.

      OutputNumber

      The result of dividing the dividend with the divisor.

      Drop

      Remove items from the beginning of an Array or String.

      Input

      • ArrayArray \| String

        The input value.

      • CountNumber

        Number of items to remove.

      OutputArray \| String

      A copy of the list without the first items.

      Drop last

      Remove item(s) from the end of an Array or String.

      Input

      • ArrayArray \| String

        The input value.

      • CountNumber

        Number of items to remove.

      OutputArray \| String

      A copy of the list without the last item(s).

      Encode JSON

      Encode data as JSON.

      Input

      • DataAny

        The data to convert.

      • IndentNumber

        How many characters the encoded value will be indented.

      OutputString

      The encoded JSON value.

      Encode URI Component

      Encode a URI component, escaping certain characters to their UTF-8 representation.

      Input

      • URIComponentString

        The URI component to encode.

      OutputString

      The encoded URI component.

      Encode to base64

      Encode a string to base64.

      Input

      • ValueString

        The input string to be encoded.

      OutputString

      The base 64 encoded string.

      Entries

      Get an Array of entries from a given Object.

      Input

      • ObjectObject

        Input record

      OutputArray

      Returns an Array of entries for the given input record. The entries are Objects with a “Key” and “Value” property.

      Equals

      Compute if values are identical.

      Input

      • FirstAny

        First Value

      • SecondAny

        Second Value

      OutputBoolean

      Returns True if the input values are identical, otherwise False.

      Every

      Run a formula returns for all items in an Array.

      Input

      • ArrayArray

        The array of items to evaluate.

      • FormulaFormula

        Predicate formula for evaluating each item.

      OutputArray

      Returns True if the predicate formula returns true for all items in the Array, otherwise False.

      Filter

      Return a new Array containing only the elements for which the provided formula evaluates to True.

      Input

      • ArrayArray

        The array of items to be filtered.

      • FormulaFormula

        Predicate formula for filtering items.

      OutputArray

      New Array containing only the items for which the Formula evaluated to True.

      Find

      Search through an Array of items and apply a formula to each item, to return the first item where the provided formula returns True.

      Input

      • ArrayArray

        The array to search through

      • FormulaFormula

        The predicate formula that each item in the array is passed to.

      OutputAny

      The first item in the Array where the formula returns True. Returns Null if the predicate formula did not return True for any item.

      Find Last

      Search through an Array of items and apply a formula to each item, to return the last item where the formula returns True.

      Input

      • ArrayArray

        The array to search.

      • FormulaFormula

        The predicate formula that each item in the Array is passed to.

      OutputAny

      The last item in the Array where the formula returns True. Returns Null if the predicate formula did not return True for any item.

      Find index

      Search through an Array of items and apply a formula to each item, to return the index of the first item where the formula returns True.

      Input

      • ArrayArray

        The array to search.

      • FormulaFormula

        The predicate formula that each item in the Array is passed to.

      OutputAny

      The index of the first item in the Array where the predicate formula returns True. Returns -1 if the predicate formula did not return True for any item.

      First

      Return the first item in an Array.

      Input

      • ArrayArray

        An Array of items.

      OutputAny

      The first item in the Array.

      Flatten

      Flatten a nested Array.

      Input

      • ArrayArray

        An Array containing one or more Arrays.

      OutputArray

      A flattened Array where all items in the original array are concatenated.

      Format Date

      Format a date using the Intl.DateTimeFormat API. See the [DateTimeFormat docs on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat).

      Input

      • DateDate

        Date to format

      • Locale(s)Array \| String

        Optional locale to use for formatting the Date, e.g. "en" or "fr". Multiple locales can be provided (as an Array of Strings) to provide a fallback locale. The default value is the runtime's locale.

      • OptionsObject

        Optional Object for configuring the formatting of the output. See the [DateTimeFormat syntax on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#syntax).

      OutputString

      The Date input formatted as a String.

      Format Number

      Format a Number using the Intl.NumberFormat API. See the [NumberFormat docs on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat).

      Input

      • InputNumber

        Number to format.

      • Locale(s)Array \| String

        Optional locale to use for formatting the Number, e.g. "en" or "fr". Multiple locales can be provided (as an Array of Strings) to provide a fallback locale. The default value is the runtime's locale.

      • OptionsObject

        Optional Object for configuring the formatting of the output. See the [NumberFormat locale options on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locale_options).

      OutputString

      The Number input formatted as a String.

      From entries

      Create a record from an Array of entries. This formula is the reverse of Entries.

      Input

      • ArrayArray

        The array of entries.

      OutputObject

      An Object containing all entries from the input Array.

      Get

      Extract a value from an Object, Array or String at the specified path.

      Input

      • ObjectArray \| Object \| String

        The Object, Array or String you want to extract an item from.

      • PathArray<String> \| Number \| String

        The Path can be either a Number, a String, or an Array.

      OutputAny

      The value found at the Path. If no value is found, this value of the output is Null.

      Get Cookie

      Get the value of a cookie by name. This formula is available both server-side and client-side. Http-Only cookies will only be available server-side.

      Input

      • Cookie nameString

        The name of the cookie you want to get the value of.

      OutputString

      The value of the cookie. If a value is not found, this return value will be Null.

      Get Http-Only Cookie

      Get the value of an Http-Only cookie by name. This formula will is only intended to be used server-side for SSR/proxied API requests to read Http-Only cookies.

      Input

      • Cookie nameString

        The name of the Http-Only cookie you want to get the value of.

      OutputString

      The value of the cookie. If no cookie is found, this will return Null. If you use this formula client-side, it will return a placeholder template string.

      Get element by id

      Return a DOM element with a given id.

      Input

      • IdString

        The id of the DOM element to return.

      OutputElement

      The DOM element with the given id. If no DOM element is found, this will return Null.

      Get from Local Storage

      Read a value from local storage with the provided key.

      Input

      • KeyString

        The key to read from local storage.

      OutputAny

      The value found in local storage. If no value is found, this will return Null.

      Get from Session Storage

      Read a value from session storage with the provided key.

      Input

      • KeyString

        The key to read from session storage.

      OutputAny

      The value found in session storage.

      Greater or equal

      Compute whether a value is larger than or equal to another value.

      Input

      • FirstNumber

        First value to be compared.

      • SecondNumber

        Second value to be compared.

      OutputBoolean

      Returns True if the first Number is larger than or equal to the second Number.

      Greater than

      Compute if a value is larger than another value.

      Input

      • FirstNumber

        First value to be compared.

      • SecondNumber

        Second value to be compared.

      OutputBoolean

      Returns True if the first Number is larger than the second Number.

      Group by

      Group an Array of items into an Object based on a grouping formula.

      Input

      • ArrayArray

        Array of items to be grouped.

      • FormulaFormula

        The grouping formula used to group the items. The String returned from the formula will match the key in the output Oject.

      OutputObject

      An Object where each key matches a value returned by the grouping formula, and each value is the list of items that share the return value.

      Includes

      Test if an Array or String includes a specific item or value.

      Input

      • ArrayArray \| String

        The value to search.

      • ItemAny

        The item or value to search for.

      OutputBoolean

      Returns True if the item or value exists in the Array or string. Returns False if no match is found.

      Index of

      Find the index of a specific item in an Array or String.

      Input

      • ArrayArray \| String

        The value to search.

      • ItemAny

        The items to search for.

      OutputNumber

      If the item exists in the Array, the index of that item is returned. If the item is not found, -1 is returned.

      Is Server

      Get information about whether formulas are currently evaluated server-side or client-side.

      Input

        OutputBoolean

        Returns True if formulas are evaluated server-side, and False if formulas are evaluated client-side.

        JSON

        Convert a value into a JSON String.

        Input

        • InputAny

          The input value.

        • IndentationNumber

          The number of spaces used for indentation in the JSON String.

        OutputString

        The JSON String.

        Join

        Combine an Array of Strings in to a single String.

        Input

        • ArrayArray

          An array of Strings.

        • SeparatorString

          A separator String that is inserted in between each item in the Array to join.

        OutputString

        A String combining each item in the input Array separated by the separator String, e.g. joining ["a", "b", "c"] with a "," separator will return "a,b,c".

        Key by

        Organize an Array of items into an Object based on a Key formula.

        Input

        • ArrayArray

          Array of items.

        • FormulaFormula

          The key formula used to index the items. The String returned from the formula will match the key in the output Object.

        OutputObject

        An Object where each key matches a value returned by the key formula, and each value is the item that String was returned for.

        Languages

        An array of the preferred languages for the user, based on the Navigator.languages property (on the client) or the Accept-Language header (on the server).

        Input

          OutputArray

          An array with the preferred languages for the user.

          Last

          Get the last item in an Array.

          Input

          • ArrayArray

            The input Array.

          OutputAny

          The last item in the Array.

          Last Index of

          Search an Array or String to find the index of the last occurrence of a specified item or substring.

          Input

          • ArrayArray \| String

            The value to search.

          • ItemAny

            The item or substring to search for.

          OutputNumber

          If the item or substring exists in the Array, the last index of that item is returned. If the item is not found, -1 is returned.

          Less or equal

          Compute if a value is smaller than or equal to another value.

          Input

          • FirstNumber

            First Number to be compared.

          • SecondNumber

            Second Number to be compared.

          OutputBoolean

          Returns True if the First Number is smaller than or equal to the second Number, otherwise it returns False.

          Less than

          Compute if a value is smaller than another value.

          Input

          • FirstNumber

            First Number to be compared.

          • SecondNumber

            Second Number to be compared.

          OutputBoolean

          Returns True if the First Number is smaller than the second Number, otherwise it returns False.

          Logarithm

          Return the logarithm of a Number.

          Input

          • NumberNumber

            A Number greater than or equal to 0.

          OutputNumber

          The natural logarithm of the Number.

          Lower case

          Convert a string to lowercase.

          Input

          • StringString

            Input String

          OutputString

          The input String with all characters converted to lowercase.

          Map

          Run a formula on each item of an Array to return a new Array.

          Input

          • ArrayArray

            The Array of items.

          • FormulaFormula

            The formula to run on each item of the Array.

          OutputArray

          A new Array containing all the values returned from running the provided formula on each item in the provided input Array.

          Matches

          Finds the (global) matches in a String based on a regular expression.

          Input

          • InputString

            The string to search for matches in.

          • Regular expressionString

            The regular expression to use for matching.

          • Global searchBoolean

            Test the regular expression against all possible matches in a string.

          • Case insensitiveBoolean

            Ignore case while attempting a match in a string.

          • Multi lineBoolean

            Treat multiline strings as multiple lines.

          OutputArray

          An Array of Strings

          Max

          Find the largest Number from a list of inputs.

          Input

          • 0Number

            Input Number.

          • 1Number

            Input Number.

          OutputNumber

          The largest of the input Numbers.

          Min

          Find the smallest Number from a list of inputs.

          Input

          • 0Number

            Input number

          • 1Number

            Input number

          OutputNumber

          The smallest of the input Numbers.

          Minus

          Subtract a Number from a Number.

          Input

          • MinuendNumber

            The number to subtract from.

          • SubstrahendNumber

            The number to subtract.

          OutputNumber

          The result of subtracting the Substrahend from the Minuend.

          Modulo

          Get the remainder when dividing two Numbers.

          Input

          • DividendNumber

            The number to be divided.

          • DividerNumber

            The number to divide by.

          OutputNumber

          The remainder when the Dividend is divided by the Divider.

          Multiply

          Multiply two or more Numbers.

          Input

          • 0Number

            Number to be multiplied.

          • 1Number

            Number to be multiplied.

          OutputNumber

          The product of multiplying the input Numbers.

          Not

          Get the Boolean opposite of an input value.

          Input

          • InputBoolean

            The input value.

          OutputBoolean

          Returns True if the input value is False, and False if the input value is True.

          Not equal

          Compute if values are not identical.

          Input

          • FirstAny

            First value.

          • SecondAny

            Second value.

          OutputAny

          Returns True if the values are not identical, otherwise False.

          Now

          Get a Date representing "Now"

          Input

            OutputDate

            A Date object initialized at the current date/time.

            Number

            Convert a value of any type to a Number.

            Input

            • InputAny

              Value of any type

            OutputNumber

            The input value converted to a Number.

            Parse JSON

            Parse a String to JSON.

            Input

            • JSON stringString

              The String to be parsed.

            OutputAny

            The parsed JSON value. If the input is not a valid String, this returns Null.

            Parse URL

            Parse a URL

            Input

            • URLString

              The URL value to parse.

            • BaseString

              An optional base for the URL. Use this to resolve relative URLs.

            OutputObject

            An object containing: "hostname", "searchParams", "path", "hash", "href", "protocol", "port", "origin"

            Power

            Raise a number to a power.

            Input

            • BaseNumber

              The number to be raised to the exponent.

            • ExponentNumber

              The exponent to raise the base to.

            OutputNumber

            The result of raising the base to the exponent.

            Prepend

            Add an element to the start of an Array.

            Input

            • ArrayArray

              The Array to prepend to.

            • ItemAny

              The item to prepend to the Array.

            OutputArray

            A new Array containing the new item and all the elements from the input Array.

            Random number

            return a random Number between 0 and 1.

            Input

              OutputNumber

              A random Number between 0 and 1.

              Range

              Create an Array of numbers between a Min and Max value.

              Input

              • MinNumber

                The smallest value in the list.

              • MaxNumber

                The largest value in the list.

              OutputArray

              An Array containing all the numbers between Min and Max, inclusive.

              Reduce

              Reduce a group of items to a single value by applying each item to a reducer formula.

              Input

              • ArrayArray \| Object

                The Array or Object of items to be reduced.

              • FormulaFormula

                The reducer formula. Each item in the Array is applied to the formula along with the accumulator. The result of this formula will be a new accumulator used for the next item.

              • AccumulatorAny

                The initial value of the accumulator. This value is passed to the reducer formula along with the first item in the Array, and the result is used as the accumulator for the next item.

              OutputAny

              The value returned from applying the last item to the reducer formula.

              Replace all

              Replace all occurrences of a substring in a String.

              Input

              • InputString

                The input String to search in.

              • SearchString

                The substring to search for.

              • Replace withString

                The replacement value.

              OutputString

              The resulting String.

              Reverse

              Reverse the order of an Array.

              Input

              • ArrayArray

                The Array to be reversed.

              OutputArray

              The reversed Array.

              Round

              Round a Number to the nearest decimal point.

              Input

              • InputNumber

                Number to round.

              • DecimalsNumber

                Number of decimals to round to.

              OutputNumber

              The rounded Number.

              Round down

              Round a Number down to the nearest decimal point.

              Input

              • InputNumber

                Number to round down.

              • DecimalsNumber

                Number of decimals to round to.

              OutputNumber

              The rounded Number.

              Round up

              Round a Number up to the nearest decimal point.

              Input

              • InputNumber

                Number to round up.

              • DecimalsNumber

                Number of decimals to round to.

              OutputNumber

              The rounded Number.

              Set

              Set a value in an Object or Array based on a specified path.

              Input

              • ObjectObject

                The input Object.

              • PathArray \| Number \| String

                The Path can be either a Number, a String or an Array of Strings.

              • ValueAny

                The value to set.

              OutputObject

              The input Object with the new field.

              Shuffle

              Shuffle items in an Array or String.

              Input

              • ArrayArray \| String

                The input value.

              OutputArray \| String

              The shuffled Array or String.

              Size

              Get the size of an Array, Object or String.

              Input

              • CollectionArray \| Object \| String

                The collection to get the size of.

              OutputNumber

              The size of the collection.

              Some

              Run a formula on all items of an Array to determine if any item matches a set of conditions.

              Input

              • ArrayArray

                The Array of items to evaluate.

              • FormulaFormula

                Predicate formula for evaluating each item.

              OutputBoolean

              Returns True if the predicate formula returns True for any items in the Array, otherwise False.

              Sort by

              Sort an Array using a formula.

              Input

              • ArrayArray

                The input Array.

              • FormulaFormula

                The sorting formula. The output of this formula will determine the sort order of the items. If the formula returns an Array, the items will first be sorted by the first item, then the second, etc.

              • Ascending?Boolean

                Should the list be sorted in ascending order?

              OutputNumber

              The input Array sorted by the value returned by the sorting formula.

              Split

              Split a String into an Array of smaller strings each time a delimiter occurs. The delimiter will not be part of the output

              Input

              • InputString

                The String to split.

              • DelimiterString

                The string to split by.

              OutputArray

              An array of Strings.

              Square root

              Get the square root of a Number.

              Input

              • NumberNumber

                The input Number.

              OutputNumber

              The square root of the input Number.

              Starts with

              Check if a String has a given prefix.

              Input

              • StringString

                The String to check.

              • PrefixString

                The prefix to check for.

              OutputBoolean

              Returns True if the input String starts with the prefix, otherwise False

              String

              Convert a value of any type to a String.

              Input

              • InputAny

                Value of any type.

              OutputString

              The input value converted to a String

              Sum

              Return the sum of an Array of numbers

              Input

              • ArrayArray

                The array of numbers to sum.

              OutputNumber

              The total sum from adding all the numbers in the Array.

              Take

              Take items from the start of an Array or String.

              Input

              • ArrayArray \| String

                Input Array or String.

              • CountNumber

                Number of items to take.

              OutputArray \| String

              The first items from the Array or String.

              Take last

              Take items from the end of an Array or String.

              Input

              • ArrayArray \| String

                The input value.

              • CountNumber

                Number of items to take.

              OutputArray \| String

              The last items from the Array or String.

              Timestamp

              Get the timestamp from a Date, e.g. 1633462980000.

              Input

              • DateDate

                The date to get the timestamp from.

              OutputNumber

              The timestamp from the date input.

              Trim

              Remove any leading and trailing white spaces from a String.

              Input

              • StringString

                The String to trim.

              OutputString

              The trimmed String.

              Type of

              Get the type of a given input.

              Input

              • InputAny

                The input value.

              OutputAny

              The type of the input value. Types can be one of: String, Boolean, Number, Array, Object, or Null.

              Unique

              Remove duplicate values from an Array.

              Input

              • ArrayArray

                The input Array.

              OutputArray

              The input Array with all duplicate values removed.

              Uppercase

              Convert a String to uppercase.

              Input

              • StringString

                Input String.

              OutputString

              The input String with all characters converted to uppercase.

              User Agent

              Get the user agent for the browser or from the User-Agent header on the server

              Input

                OutputString

                The user agent string.

                Stop scrolling. Start building.

                toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

                Try toddle — it's free!

                © Copyright 2024 toddle. All rights reserved.