# Align to make wires straight

**URL:** <https://discourse.nodered.org/t/align-to-make-wires-straight/99223>\
**Category:** General\
**Created:** [30 September 2025 08:49 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223 "2025-09-30T08:49:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [30 September 2025 08:49 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/1 "2025-09-30T08:49:38Z")

</div>

Hi There,

I have this pedantic streak that likes straight lines especially when creating flows.

Question: how do I align (other than doing it manually) the two nodes so that the wire is straight:

![align-straight-line](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/6/766cb9413d2ababdcfe738d67ed2747b36920c2c.gif)

Align top, middle and bottom are shown but because they use the edges of the nodes, the wire is never straight. Perhaps an `align-to-straight-line` would be a nice feature for the artisans amongst us!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 September 2025 09:26 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/2 "2025-09-30T09:26:21Z")

</div>

Change the snap to grid size in the setting menu. 12.5 works great for nodes with an odd number of outputs.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 September 2025 09:28 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/3 "2025-09-30T09:28:03Z")

</div>

If your grid size is not a multiple/divisor of the vertical port spacing, then getting them aligned will mean one of the nodes having to be ‘off grid’.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 September 2025 09:34 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/4 "2025-09-30T09:34:47Z")

</div>

(was just passing by and noticed the thread.)

Just out of interest, what is the magic number of the vertical port spacing?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 September 2025 09:35 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/5 "2025-09-30T09:35:09Z")

</div>

I feel your pain often too.  
🙂

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [30 September 2025 09:45 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/6 "2025-09-30T09:45:36Z")

</div>

> [@dceejay](#):
>
> Change the snap to grid size in the setting menu.

Thanks for the suggestion and it does sound like a solution ... however .... that for me is a manual solution - I don't use snap to grid, so I would have activate and deactivate just for alignment.

I had a quick look at the [implementation](https://github.com/node-red/node-red/blob/0c923320330c1a0a387d664f9038caca860793ee/packages/node_modules/%40node-red/editor-client/src/js/ui/view-tools.js#L452-L554) and realised that there isn't a "easy" way to align on ports instead of node edges. Then the thought struck me: what it's the third point from the top on the switch node (for example)? I.e., the location of the ports in the order is total important - since I was thinking of aligning ports not node edges.

Besides aligning on ports would require knowing how a port movements affect the position of the node.

Ah, oh well - there seems to be no quick fix ...

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 September 2025 09:58 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/7 "2025-09-30T09:58:47Z")

</div>

Ok, going out on a limb......

`5` is the smallest snap size I use/like in/on my grids.  
`10` at a pinch if it isn't very populated.

Normally when putting nodes beside one another the in/out points align.

~~So, if the `node height` is.... something weird like `13`.....~~  
~~If you have multiple outputs and the output points are (say) `5` apart, this way madness lies.~~

Because if the _offset_ from the bottom of the node and the point is not `5` it is going to be hard/difficult to have extra outputs to align with the overwhelming grid.

Alas for an overall solution the vertical size of nodes with more than one output would have to be made higher so the outputs would alight with the `5x5` grid.

MAYBE if the greater grid size was set to `6` it may be better as `6` is a bit more factorisable.  
(3 and 2)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 September 2025 10:42 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/8 "2025-09-30T10:42:02Z")

</div>

6.25 would align all the existing ports, but is a bit small for me hence why I suggested 12.5 which works for nodes with an odd number of ports.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 September 2025 10:46 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/9 "2025-09-30T10:46:46Z")

</div>

Sorry, I was probably ranting.

Reading your post _again_ (for the first time - sorry)

So 12.5 works for nodes with an ODD number of outputs.

(You know where I'm going.)

What happens then?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 September 2025 10:51 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/10 "2025-09-30T10:51:38Z")

</div>

No. I don’t know where you’re going. Did you try it and see ?

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [30 September 2025 10:57 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/11 "2025-09-30T10:57:54Z")

</div>

> [@Trying\_to\_learn](#):
>
> So 12.5 works for nodes with an ODD number of outputs.

Wait, what:

 ![Screenshot 2025-09-30 at 12.57.07](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5cc55af30c861f222a620e2cfc9618ea1064922e.png)

12.5 isn't allowed or is red something good here 😉

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 September 2025 11:15 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/12 "2025-09-30T11:15:41Z")

</div>

I'm really not sure where I was going with my post.

Odd/Even output numbered nodes would be ..... problematic to handle.

Unless the distance from the top/bottom of the node and the output node was a bit _dynamic_ and could be changed depending if the number of outputs was odd or even.

Then the outputs could be _adjusted_ up/down to lock onto the greater grid's lines.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [30 September 2025 13:23 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/13 "2025-09-30T13:23:07Z")

</div>

> [@gregorius](#):
>
> 12.5 isn't allowed or is red something good here

Technically, it would work… but given this is about pixels, drawing things with a 0.5 pixel offset will risk things getting a little fuzzy.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [30 September 2025 13:33 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/14 "2025-09-30T13:33:01Z")

</div>

> [@knolleary](#):
>
> fuzzy.

[fuzzy wuzzy bear](https://playtivities.com/fuzzy-wuzzy-was-a-bear/) or pixel in this case ...

So @dceejay are you selling fuzzy wuzzy snake oil with your 12.5 pixels 😉 - I'm definitely not going down that road - it'll only end with me and a magnifying glass counting fuzzy pixels on laptop screen.

---

<div class="post-metadata">

**Author:** ![AllanOricil](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allanoricil/32/106911_2.png) [@AllanOricil](https://discourse.nodered.org/u/AllanOricil)\
**Post date:** [30 September 2025 13:34 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/15 "2025-09-30T13:34:20Z")

</div>

I suffer with this too.  
But I once realized that straightening the wire automatically would only really work when there is an odd number of ports and only for the wire connected to the middle port. In your example, try to place 4 nodes, one for each of the output ports, and manually straight the 4 wires and you will see there is an overlap between nodes. To let us straight all wires, no matter the number of ports, it would be necessary to dynamically increase the space between ports. All ports would have to have a margin equal to the height of a node with a single port + an additional space between inner ports to avoid having the wired nodes too close to each other

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [30 September 2025 14:05 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/16 "2025-09-30T14:05:02Z")

</div>

The example at the bottom grates with me

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/71ded7b337c148dd23c4e61030479a222c45e12d.png)

So does the work-around with additional ports and 25px grid spacing.  
(picture redacted for @gregorius' placidity). View edit history at your discretion!

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [30 September 2025 14:14 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/17 "2025-09-30T14:14:15Z")

</div>

Oh f2k'g OMG - don't do that, I'm going to have nightmares now. My autistic self is wondering whether the lines in the second example are straight or not ... the top three. I hate these optical illusions in Node-RED - drives me batty.

---

<div class="post-metadata">

**Author:** ![AllanOricil](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allanoricil/32/106911_2.png) [@AllanOricil](https://discourse.nodered.org/u/AllanOricil)\
**Post date:** [30 September 2025 14:23 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/18 "2025-09-30T14:23:38Z")

</div>

Im pretty sure they aren't. I can slightly see an angle comming from the output ports of the switch node 🥲

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [30 September 2025 14:25 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/19 "2025-09-30T14:25:00Z")

</div>

I hid the picture. Sleep well 🫠

The wires _should be_ straight and parallel - they run along a grid line. Unless the port spacing is not 12.5px?

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [30 September 2025 14:33 UTC](https://discourse.nodered.org/t/align-to-make-wires-straight/99223/20 "2025-09-30T14:33:11Z")

</div>

> [@jbudd](#):
>
> I hid the picture. Sleep well 🫠

🙂

Thank you - It might just have been a little over emphasised on my part - don't worry, I won't be having nightmares because of that image - especially since I'm doing my own alignment here.

I'm quite amazed that they were parallel, they really seemed off for me ... weird.

[Next page](https://discourse.nodered.org/t/align-to-make-wires-straight/99223.md?page=2)
