# Indentation error in scripts

**URL:** <https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [July 31, 2025, 2:54pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206 "2025-07-31T14:54:16Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [July 31, 2025, 2:54pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/1 "2025-07-31T14:54:16Z")

</div>

Hi everyone,

I need help with how to get rid of indentation error that comes in script files for no reason.  
I know that there should be no identation error but I get it. It does not go away very easily.  
Here is a screenshot-  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/b/9bb5dc9e1434f9d6421224a38133eb901b5161a7.png)

I have to try really hard sometimes to get rid of this.

It feels like it is a bug.  
Any suggestion on getting rid of this issue permanently?

Thanks & regards,  
Ajay Kumar Gupta

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [July 31, 2025, 3:00pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/2 "2025-07-31T15:00:07Z")

</div>

We can't tell without seeing the previous lines. If that's inside a function at the root level of the script and isn't nested under some other expression, then it is indented one too far.

---

<div class="post-metadata">

**Author:** ![Kyle.Chase](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@Kyle.Chase](https://forum.inductiveautomation.com/u/Kyle.Chase)\
**Post date:** [July 31, 2025, 3:00pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/3 "2025-07-31T15:00:59Z")

</div>

You are either indented to the wrong "level", or are using tabs and spaces interchangeably, which you can not do in Python. Post the whole scripts and we can help.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [July 31, 2025, 3:13pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/4 "2025-07-31T15:13:27Z")

</div>

Right click in the editor space -\> appearance -\> whitespace. This should allow you to determine if you have mixed spaces and tabs. Also make sure you aren't missing any colons or brackets.

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [July 31, 2025, 3:44pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/5 "2025-07-31T15:44:36Z")

</div>

can you give us the actual scripts?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [July 31, 2025, 5:21pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/6 "2025-07-31T17:21:21Z")

</div>

> [@Ajay\_Gupta](#):
>
> It feels like it is a bug.

Yes, it is a bug in your code (which we are still waiting for). Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![bebel](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bebel](https://forum.inductiveautomation.com/u/bebel)\
**Post date:** [September 3, 2025, 12:06pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/7 "2025-09-03T12:06:04Z")

</div>

I found this post after having a bunch of problems with this. The suggestion to turn on Whitespace was the game changer. It makes things much easier to fix once you get used to linking the clues to the proper corrective action. I have a fair amount of code pasted from chatgpt, which I think is what got my script editor so messed up. I’m wondering if others have linked the cause to pasting code from there.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 3, 2025, 12:09pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/8 "2025-09-03T12:09:05Z")

</div>

> [@bebel](#):
>
> wondering

Probably not, considering LLMs' poor performance with Ignition's niche jython usage.

(Do read the FAQ about posting LLM output here.)

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [September 3, 2025, 1:04pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/9 "2025-09-03T13:04:22Z")

</div>

Agreed- The suggestion to turn on Whitespace was the game changer.  
For me it is not copy paste.  
It just happens. Even with the code that has been working. If i add a new line of code suddenly it starts erroring out. Especially if there is a commented line and i add a new line after that.  
Just random.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 3, 2025, 2:03pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/10 "2025-09-03T14:03:31Z")

</div>

I really doubt that the python editor somehow randomly starts misinterpreting indentation...

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [September 3, 2025, 2:30pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/11 "2025-09-03T14:30:17Z")

</div>

I seem to have random indentation issues periodically. It looks correct, but the error persists. I can fix one line, and the issue moves to another line. When this happens, I paste into VS code, nudge all code right and then back left, then paste back into Ignition.

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [September 3, 2025, 4:04pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/12 "2025-09-03T16:04:38Z")

</div>

That’s exactly happens with my team as well.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 3, 2025, 4:41pm UTC](https://forum.inductiveautomation.com/t/indentation-error-in-scripts/109206/13 "2025-09-03T16:41:41Z")

</div>

Never seen that... But I do most coding in an external editor.
