Splitting A String Every 2,000 Characters

I’m sending emails to Notion, as page content and Notion’s API only allows 2,000 characters to be included in a rich text object. So I need to break the email content down into an array of strings, where each string is the next 2,000 characters from the email.

I know that I can use slice() to get characters from a string but I’m not sure how to loop through each block of 2,000 characters and store those as an array.

I need to be able to format each block of content as:

    "type": "paragraph",
    "paragraph": {
        "rich_text": [
                "text": {
                    "content": [2,000 characters]

so that it can be added to the Notion page using the Append A Page Content module. Appreciate any tips!

Hi there,
I dont know if this is the best solution but you can use regex to get several bundles:

To get the last characters you have to get the length of the string and substring the last characters which where not inside the regex bundles.


Thanks for this, I was hoping to avoid Regex because it can be a little bit unpredictable but if there’s no way to do this with Make’s other functions then it looks like that should work for me.

You can use the iterator to fill an array and the array aggregator to join them again.
But the regex match pattern is much easier :slight_smile:


Hi @alexs,

As mentioned previously, you can use the substring function, and repeater alongside either a Text Aggregerator or Create JSON module to get the JSON format that you are seeking.

You can test this blueprint,

blueprint (53).json (6.4 KB)

However, you can directly use the regex as suggested previously as it will be lot cleaner.


Thanks for sharing this Blueprint, that works great.

In the end, I realised that splitting the text into 2,000 character chunks isn’t a great idea because it would mean that some paragraphs would be split into two separate blocks, when they’re added to the Notion page.

So instead, I’m assuming that my paragraphs will be less than 2,000 characters and creating 1 block per paragraph.

Those modules are configured like this -

Thanks to everyone who commented for your suggestions!

1 Like