# Split node, data split

**URL:** <https://discourse.nodered.org/t/split-node-data-split/85193>\
**Category:** General\
**Created:** [4 February 2024 17:03 UTC](https://discourse.nodered.org/t/split-node-data-split/85193 "2024-02-04T17:03:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pjlals](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pjlals/32/69483_2.png) [@Pjlals](https://discourse.nodered.org/u/Pjlals)\
**Post date:** [4 February 2024 17:03 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/1 "2024-02-04T17:03:50Z")

</div>

````auto
```[
    {
        "id": "bc97ba3b1120916d",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "6b91f71dcb05eef7",
        "type": "split",
        "z": "bc97ba3b1120916d",
        "name": "",
        "splt": "\\n",
        "spltType": "len",
        "arraySplt": "5",
        "arraySpltType": "len",
        "stream": true,
        "addname": "",
        "x": 330,
        "y": 700,
        "wires": [
            [
                "8ebdd414a78f64ea",
                "8005318185fbaf88"
            ]
        ]
    },
    {
        "id": "c435cfde1c588352",
        "type": "ui_text_input",
        "z": "bc97ba3b1120916d",
        "name": "",
        "label": "scan",
        "tooltip": "",
        "group": "2decf6b88dbcceaf",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": 300,
        "topic": "topic",
        "topicType": "msg",
        "x": 150,
        "y": 700,
        "wires": [
            [
                "6b91f71dcb05eef7"
            ]
        ]
    },
    {
        "id": "8ebdd414a78f64ea",
        "type": "ui_text",
        "z": "bc97ba3b1120916d",
        "group": "2decf6b88dbcceaf",
        "order": 3,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "fixed ",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 490,
        "y": 700,
        "wires": []
    },
    {
        "id": "8005318185fbaf88",
        "type": "ui_text",
        "z": "bc97ba3b1120916d",
        "group": "2decf6b88dbcceaf",
        "order": 4,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "variable",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "x": 500,
        "y": 760,
        "wires": []
    },
    {
        "id": "2decf6b88dbcceaf",
        "type": "ui_group",
        "name": "description",
        "tab": "32c3866651e1e470",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "32c3866651e1e470",
        "type": "ui_tab",
        "name": "testing tab",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]```

hi all , how to use the split , i am trying to get a data input in scan form via usb scanner, the data should be splited into fixed and varaible text output node ,for example , if i input a characters of helloworld, after 4 characters it should be split into fixed (hello) and variable (world) text output node`Preformatted text`
````

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 February 2024 17:22 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/2 "2024-02-04T17:22:40Z")

</div>

Your post needs editing as your backticks need to be on their own line.

You need to enter a number into fixed length for string split. Then route the payloads using msg.parts.index. Use a debug node set to complete message object to see all message properties after the split.

e.g

```auto
[{"id":"c435cfde1c588352","type":"ui_text_input","z":"bc97ba3b1120916d","name":"","label":"scan","tooltip":"","group":"2decf6b88dbcceaf","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"topic","topicType":"msg","x":150,"y":700,"wires":[["6b91f71dcb05eef7"]]},{"id":"6b91f71dcb05eef7","type":"split","z":"bc97ba3b1120916d","name":"","splt":"5","spltType":"len","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":330,"y":700,"wires":[["7dc761f8023a402b","36b8f2117d8b4d9e"]]},{"id":"7dc761f8023a402b","type":"switch","z":"bc97ba3b1120916d","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":700,"wires":[["8ebdd414a78f64ea"],["8005318185fbaf88"]]},{"id":"36b8f2117d8b4d9e","type":"debug","z":"bc97ba3b1120916d","name":"debug 2479","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":410,"y":640,"wires":[]},{"id":"8ebdd414a78f64ea","type":"ui_text","z":"bc97ba3b1120916d","group":"2decf6b88dbcceaf","order":3,"width":0,"height":0,"name":"","label":"fixed ","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":"","color":"#000000","x":610,"y":700,"wires":[]},{"id":"8005318185fbaf88","type":"ui_text","z":"bc97ba3b1120916d","group":"2decf6b88dbcceaf","order":4,"width":0,"height":0,"name":"","label":"variable","format":"{{msg.payload}}","layout":"row-spread","x":620,"y":760,"wires":[]},{"id":"2decf6b88dbcceaf","type":"ui_group","name":"description","tab":"32c3866651e1e470","order":1,"disp":true,"width":"6","collapse":false},{"id":"32c3866651e1e470","type":"ui_tab","name":"testing tab","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [4 February 2024 17:24 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/3 "2024-02-04T17:24:27Z")

</div>

> [@E1cid](#):
>
> Your post needs editing as your backticks need to be on their own line.

I was about to get grumpy about providing no context! - until I scrolled down the code 🫠

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 February 2024 17:28 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/4 "2024-02-04T17:28:47Z")

</div>

> [@marcus-j-davies](#):
>
> grumpy

Not allowed, deep breaths, I hear music soothes the soul.

---

<div class="post-metadata">

**Author:** ![Pjlals](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pjlals/32/69483_2.png) [@Pjlals](https://discourse.nodered.org/u/Pjlals)\
**Post date:** [4 February 2024 17:53 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/5 "2024-02-04T17:53:20Z")

</div>

thanks for the reply , data is getting splitted into 4 characters(fixed) & 4 (variables)haracters

for example , if a a word (helloworld) of 10 characters , in fixed i want only 4 characters and remainig in variable text output , is it possible ?

---

<div class="post-metadata">

**Author:** ![Pjlals](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pjlals/32/69483_2.png) [@Pjlals](https://discourse.nodered.org/u/Pjlals)\
**Post date:** [4 February 2024 17:56 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/6 "2024-02-04T17:56:49Z")

</div>

, edited, pasting the code format is correct ? @marcus-j-davies

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [4 February 2024 18:06 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/7 "2024-02-04T18:06:03Z")

</div>

Don't sweat it's fine! 😄

Your providing commentary was inside the 3 ``` making it look like you didn't providing any context, but you did - you're off the hook 😉

Should be...

````auto
```
Code
```
Your comments

````

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 February 2024 18:09 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/8 "2024-02-04T18:09:35Z")

</div>

This could also be done in a function node using Javascript or a change node using JSONata, but here is the low code way.

```auto
[{"id":"aca93cd0f4471603","type":"ui_text_input","z":"d1395164b4eec73e","name":"","label":"scan","tooltip":"","group":"abdf61b808295e6a","order":2,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"topic","topicType":"msg","x":571.9999732971191,"y":5701.000201225281,"wires":[["75b04f722a0b6862"]]},{"id":"75b04f722a0b6862","type":"split","z":"d1395164b4eec73e","name":"","splt":"4","spltType":"len","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":711.9999732971191,"y":5701.000201225281,"wires":[["3026e7cb4aa022c2","265b635ea5a23dee"]]},{"id":"3026e7cb4aa022c2","type":"debug","z":"d1395164b4eec73e","name":"debug 2479","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":831.9999732971191,"y":5641.000201225281,"wires":[]},{"id":"265b635ea5a23dee","type":"switch","z":"d1395164b4eec73e","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":true,"outputs":2,"x":931.9999732971191,"y":5661.000201225281,"wires":[["c8b19db71bc81b7d"],["0bcc382a0642d0d2"]]},{"id":"c8b19db71bc81b7d","type":"ui_text","z":"d1395164b4eec73e","group":"abdf61b808295e6a","order":3,"width":0,"height":0,"name":"","label":"fixed ","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":"","color":"#000000","x":1071.9999732971191,"y":5661.000201225281,"wires":[]},{"id":"0bcc382a0642d0d2","type":"join","z":"d1395164b4eec73e","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":791.9999732971191,"y":5761.000201225281,"wires":[["1d3db2329acb3cd3"]]},{"id":"1d3db2329acb3cd3","type":"ui_text","z":"d1395164b4eec73e","group":"abdf61b808295e6a","order":4,"width":0,"height":0,"name":"","label":"variable","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":"","color":"#000000","x":1041.9999732971191,"y":5761.000201225281,"wires":[]},{"id":"abdf61b808295e6a","type":"ui_group","name":"description","tab":"32c3866651e1e470","order":1,"disp":true,"width":"6","collapse":false},{"id":"32c3866651e1e470","type":"ui_tab","name":"testing tab","icon":"dashboard","disabled":false,"hidden":false}]

```

[edit] removed unnecessary branching and therefore msg cloning

---

<div class="post-metadata">

**Author:** ![Pjlals](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pjlals/32/69483_2.png) [@Pjlals](https://discourse.nodered.org/u/Pjlals)\
**Post date:** [4 February 2024 18:19 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/9 "2024-02-04T18:19:23Z")

</div>

@E1cid thanks , its working

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 February 2024 18:19 UTC](https://discourse.nodered.org/t/split-node-data-split/85193/10 "2024-02-18T18:19:50Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
