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 the elements from the input array and the new item

Boolean

Convert a value of any type to a Boolean.
False and Null will return False, all other values will return True

Input

  • InputAny

    Value of any type

OutputBoolean

The input value converted to a Boolean

Branch Name

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

Input

    OutputString

    Returns the name of the current branch.

    Can Share

    Returns a boolean indicating whether the provided data can be shared (with the "Share" action)

    Input

    • URL to shareString

      undefined

    • Title to shareString

      undefined

    • Text to shareString

      undefined

    Output

    null

    Capitalize

    Capitalize a string, making the first letter uppercase and the rest lowercase.

    Input

    • StringString

      Input string

    OutputString

    The capitalized string

    Clamp

    Limit the VALUE to a specified Min and Max

    Input

    • ValueNumber

      Number to round

    • MinNumber

      The smallest allowed number

    • MaxNumber

      The largest allowed number

    OutputNumber

    Returns the input value if between Min and Max. Other wise returns the Min or Max value

    Concatenate

    Concatenate 2 or more values.

    Input

    • 0Union

      undefined

    OutputUnion

    String or array containing all the input values.

    Current URL

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

    Input

      OutputString

      The browser's current URL as a string

      Date From String

      Convert a string to a Date.

      Input

      • Date stringString

        String representing a date - "August 18, 1986" for instance.

      OutputDate

      The input value converted to a Date

      Date From Timestamp

      Convert a timestamp (milliseconds) to a Date

      Input

      • TimestampNumber

        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 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

      Returns 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 is Null or False

      OutputAny

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

      Delete

      Returns a copy of the input object or array without the specified key.

      Input

      • ObjectObject

        The input record

      • PathUnion

        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 then the property at that path will be removed.

      OutputObject

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

      Divide

      Divide to numbers

      Input

      • DividendNumber

        The number to be divided

      • DivisorNumber

        The number divide by

      OutputNumber

      The result of dividing the dividend with the divisor

      Drop

      Remove items from the start of an array or String.

      Input

      • ArrayUnion

        Input array

      • Count

        Number of items to remove

      OutputUnion

      A copy of the list with out the first items

      Drop last

      Remove items from the end of an array or String.

      Input

      • ArrayUnion

        Input array

      • CountNumber

        Number of items to remove

      OutputUnion

      A copy of the list without the last items

      Encode JSON

      Encode data as JSON

      Input

      • DataAny

        The data to convert

      • IndentNumber

        How many characters indentation

      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 the given Object

      Input

      • ObjectObject

        Input record

      OutputArray

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

      Equals

      Returns TRUE if the input values are identical

      Input

      • FirstAny

        First Value

      • SecondAny

        Second Value

      OutputAny

      TRUE if the input values are identical, otherwise FALSE

      Every

      Returns TRUE if the Predicate formula returns true for all items in the array.

      Input

      • ArrayArray

        The array of items to evaluate

      • FormulaFormula

        Predicate formula for evaluating each item

      OutputArray

      TRUE if the Predicate formula returns true for all items in the array, otherwise FALSE

      Filter

      Returns a new array containing only the elements for which the predicate formula evaluated 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 the array of items and apply the predicate formula to each item. Returns the first item where the predicate 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 returned TRUE. Returns NULL if the predicate formula did not return TRUE for any item.

      Find Last

      Search through the array of items and apply the predicate formula to each item. Returns the last item where the predicate 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 last item in the array where the formula returned TRUE. Returns NULL if the predicate formula did not return TRUE for any item.

      Find index

      Search through an array of items and apply the predicate formula to each item. Returns the index of the first item where the predicate 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 index of the first item in the array where the predicate formula returned TRUE. Returns -1 if the predicate formula did not return TRUE for any item.

      First

      Get first item in an array

      Input

      • ArrayArray

        The input list

      OutputAny

      The first item in the array

      Flatten

      Flattens a nested array

      Input

      • ArrayArray

        An array containing one or more arrays

      OutputArray

      The flattened array where all items in the original array are concatenated

      Format Date

      Format a date using the Intl.DateTimeFormat API. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat for more information.

      Input

      • DateDate

        Date to format

      • Locale(s)String | Array

        Optional locale to use for formatting the Date - "en" or "fr" for instance. Multiple locales can be provided (as an Array of Strings) to provide a fallback locale. It defaults to the runtime's locale.

      • OptionsObject

        Optional object for configuring formatting. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#syntax for all options

      OutputString

      The Date input formatted as a string

      Format Number

      Format a date using the Intl.NumberFormat API. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat for more information.

      Input

      • InputNumber

        Number to format

      • Locale(s)String | Array

        Optional locale to use for formatting the Number - "en" or "fr" for instance. Multiple locales can be provided (as an Array of Strings) to provide a fallback locale. It defaults to the runtime's locale.

      • OptionsObject

        Optional object for configuring formatting. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#locale_options for all 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 with all the entries from the input array.

      Get

      Extract a value from an object, array or string at the specified path.

      Input

      • ObjectUnion

        The object, array or string you want to extract an item from

      • PathUnion

        The Path can be either a number, a string or an array.

      OutputAny

      The value found at the path. If no value is found the NULL is returned

      Get Cookie

      Get the value of a cookie by name. This formula is available both server-side and client-side. Some cookies will only be available server-side in case they are http-only cookies.

      Input

      • Cookie nameString

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

      OutputString

      The value of the cookie if found or null if not found.

      Get Http-Only Cookie

      Get the value of a http-only cookie by name. This formula will only output anything meaningful server-side, and is intended to be used 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

      Server-side: the value of the cookie if found or null if not found. Client-side: a placeholder template string.

      Get element by id

      Return a DOM element with the given id

      Input

      • IdString

        The id of the DOM element to return

      OutputElement

      The DOM element with the given id, or null if no such element exists

      Get from Local Storage

      Read a value from Local Storage with the provided key. It tries to JSON decode the value

      Input

      • KeyString

        The key to read from Local Storage

      OutputAny

      The value found in Local Storage

      Get from Session Storage

      Read a value from Session Storage with the provided key. It tries to JSON decode the value

      Input

      • KeyString

        The key to read from Session Storage

      OutputAny

      The value found in Session Storage

      Greater or equal

      Returns TRUE if the First number is larger than or equal to the second

      Input

      • FirstNumber

        First value to be compared

      • SecondNumber

        Second value to be compared

      OutputNumber

      Returns TRUE if the First number is larger than or equal to the second

      Greater than

      Returns TRUE if the First number is larger than the second

      Input

      • FirstNumber

        First value to be compared

      • SecondNumber

        Second value to be compared

      OutputNumber

      Returns TRUE if the First number is larger than the second

      Group by

      Groups an array of items into an object based on the 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 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

      Input

      • ArrayUnion

        The array to search

      • ItemAny

        The items to search for

      OutputBoolean

      True if the item exists in the array. Otherwise False

      Index of

      Find the index of a specific item in an array or string

      Input

      • ArrayUnion

        The array or string to search

      • ItemAny

        The items to search for

      OutputBoolean

      If the item exists in the array then the index of that item is returned. If the item is not found -1 is returned

      Is Server

      Returns a boolean indicating whether formulas are currently evaluated server-side or client-side.

      Input

        OutputBoolean

        A boolean indicating whether formulas are currently evaluated server-side or client-side.

        JSON

        Turn a value into a JSON string

        Input

        • InputAny

          The input value to be turned into a JSON string

        • 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 saparator that is inserted in between each item in the retuned string

        OutputString

        A string combining each item in the input array separated by the separator string.

        Key by

        Organize an array of items into an Object based on the Key formula

        Input

        • ArrayArray

          Array of items to be Organized

        • 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

          Find the last index of a specific item in an array or string

          Input

          • ArrayUnion

            The array or string to search

          • ItemAny

            The items to search for

          OutputBoolean

          If the item exists in the array then the last index of that item is returned. If the item is not found -1 is returned

          Less or equal

          Returns True if the First number is smaller than or equal to the Second

          Input

          • FirstNumber

            First value to be compared

          • SecondNumber

            Second value to be compared

          OutputNumber

          Returns True if the First number is smaller than or equal to the Second

          Less than

          Returns True if the First number is smaller than the Second

          Input

          • FirstNumber

            First value to be compared

          • SecondNumber

            Second value to be compared

          OutputNumber

          Returns True if the First number is smaller than the Second

          Lower case

          Convert a string to lowercase

          Input

          • StringString

            Input string

          OutputString

          The input string with all characters converted to lowercase

          Map

          Pass each item of an array through the Mapping formula.

          Input

          • ArrayArray

            The array of items to be mapped

          • FormulaFormula

            The mapping formula each item will be passed through

          OutputArray

          A new array containing all the values returned from passing each array item through the Mapping formula

          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

          OutputList

          A list of strings

          Max

          Find the largest number

          Input

          • 0Number

            Input number

          • 1Number

            Input number

          OutputNumber

          The largest of all the input numbers

          Min

          Find the smallest number

          Input

          • 0Number

            Input number

          • 1Number

            Input number

          OutputNumber

          The smallest of all the input numbers

          Minus

          Subtract two numbers

          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 integers

          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 all of the input numbers

          Not

          The Boolean opposite of the input value

          Input

          • InputBoolean

            The input value

          OutputBoolean

          True if the input value is False and False if the input value is True

          Not equal

          Returns True if the values are NOT identical

          Input

          • FirstAny

            First Value

          • SecondAny

            Second Value

          OutputAny

          True if the values are not identical, otherwise False

          Now

          Get a Date representing "now"

          Input

            OutputDate

            A Date object initialised 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 JSON string to be parsed

            OutputAny

            The parsed JSON value. If the input is not a valid JSON string, null is returned.

            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 with: "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 Min and Max

              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, both inclusive

              Reduce

              Reduce an array of items to a single value by applying each item to a reducer formula

              Input

              • ArrayUnion

                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 fx

              Replace all

              Replace all occurrences of a substring in a string

              Input

              • Input

                The input string to search in

              • Search

                The substring to search for

              • Replace with

                The replacement value

              Output

              The resulting string

              Reverse

              Reverse the order of an array

              Input

              • ArrayArray

                The array to be reversed

              OutputArray

              The reversed list

              Round

              Round to the nearest decimal point

              Input

              • InputNumber

                Number to round

              • DecimalsNumber

                Number of decimals to round to

              OutputNumber

              Rounded number

              Round down

              Round down to the nearest decimal point

              Input

              • InputNumber

                Number to round down

              • DecimalsNumber

                Number of decimals to round to

              OutputNumber

              Rounded number

              Round up

              Round up to the nearest decimal point

              Input

              • InputNumber

                Number to round up

              • DecimalsNumber

                Number of decimals to round to

              OutputNumber

              Rounded number

              Set

              Set a value in an object or array based on a specified path

              Input

              • ObjectObject

                The input object

              • PathUnion

                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

              Shuffles the items in an Array or String

              Input

              • ArrayUnion

                Input array or string

              OutputUnion

              The elements in the Array/String shuffled

              Size

              Get the size of a collection

              Input

              • CollectionUnion

                The array, object or string to get the size of

              OutputNumber

              The size of the collection

              Some

              Returns True if the predicate formula returns true for any items in the array.

              Input

              • ArrayArray

                The array of items to evaluate

              • FormulaFormula

                Predicate formula for evaluating each item

              OutputBoolean

              True if the predicate formula returns true for any items in the array, otherwise False

              Sort by

              Sort an array

              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 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 the 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

                Get 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

              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

              • ArrayUnion

                Input array or string

              • CountNumber

                Number of items to take

              OutputUnion

              The first items from the array or string

              Take last

              Take items from the end of an array or string.

              Input

              • ArrayUnion

                Input array or string

              • CountNumber

                Number of items to take

              OutputUnion

              The last items from the array or string

              Timestamp

              Get the timestamp from a Date - 1633462980000 for instance (the first commit to toddle)

              Input

              • DateDate

                The Date to get the timestamp from

              OutputNumber

              The timestamp from the Date input

              Trim

              Removes 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

              OutputAny

              The type of the input.
              Types can be one of:
              - String
              - Boolean
              - Number
              - Array
              - Object
              - 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 upper case

              Input

              • StringString

                Input string

              OutputString

              The input string with all characters converted to uppercase

              User Agent

              Returns 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.