# How to replace html tags in note fields?

**URL:** <https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800>\
**Category:** Help\
**Created:** [January 1, 2025, 1:18am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800 "2025-01-01T01:18:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![homocomputeris](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@homocomputeris](https://forums.ankiweb.net/u/homocomputeris)\
**Post date:** [January 1, 2025, 1:18am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/1 "2025-01-01T01:18:38Z")

</div>

Some of my cards have the following text in some fields:

```auto
。<br>。

```

I want to replace it with

```auto
。

```

Find-replace dialogue doesn’t work either for the current selected cards or any other cards. Neither with regexps nor with plain text.

How can I make the replacement? (Whatever comes up in search doesn’t work).

> Anki 24.11 (87ccd24e) (src)  
> Python 3.13.1 Qt 6.8.1 PyQt 6.8.0  
> Platform: Linux-6.12.7-zen1-1-zen-x86\_64-with-glibc2.40

---

<div class="post-metadata">

**Author:** ![homocomputeris](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@homocomputeris](https://forums.ankiweb.net/u/homocomputeris)\
**Post date:** [January 1, 2025, 1:34am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/2 "2025-01-01T01:34:37Z")

</div>

From experiments I’ve found out that replace works **only in the current card** if HTML code is shown in the editor and the cursor is placed in a HTML code field. Then, replacement works only in this focused fields. Which is basically useless.

---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [January 1, 2025, 1:45am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/3 "2025-01-01T01:45:20Z")

</div>

I’ve never had a problem Searching or Find-and-Replace-ing on raw HTML. In fact, the HTML sometimes obscures what I’m really trying to find (e.g. formatting within a word).

- Did you try your “Find” string as a Search first, to make sure it is locating the right notes?
- Are you limiting your Find to “Selected notes only” and then forgetting to select the notes?
- Are you limiting your Find to specific fields, and the text is in other fields?

---

<div class="post-metadata">

**Author:** ![homocomputeris](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@homocomputeris](https://forums.ankiweb.net/u/homocomputeris)\
**Post date:** [January 1, 2025, 2:06am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/4 "2025-01-01T02:06:06Z")

</div>

> [@Danika\_Dakika](#):
>
> Are you limiting your Find to “Selected notes only” and then forgetting to select the notes?

No.

> [@Danika\_Dakika](#):
>
> Are you limiting your Find to specific fields, and the text is in other fields?

No.

---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [January 1, 2025, 3:30am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/5 "2025-01-01T03:30:08Z")

</div>

Great. What about?

> [@Danika\_Dakika](#):
>
> Did you try your “Find” string as a Search first, to make sure it is locating the right notes?

---

<div class="post-metadata">

**Author:** ![homocomputeris](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@homocomputeris](https://forums.ankiweb.net/u/homocomputeris)\
**Post date:** [January 1, 2025, 2:08pm UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/6 "2025-01-01T14:08:30Z")

</div>

Yes, searching in browser works.

---

<div class="post-metadata">

**Author:** ![Danika\_Dakika](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/danika_dakika/32/17815_2.png) [@Danika\_Dakika](https://forums.ankiweb.net/u/Danika_Dakika)\
**Post date:** [January 1, 2025, 8:47pm UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/7 "2025-01-01T20:47:54Z")

</div>

> [@homocomputeris](#):
>
> … replace works **only in the current card** if HTML code is shown in the editor and the cursor is placed in a HTML code field.

This catches my eye. When you have multiple cards/notes selected, the note editor closes. So if you can see that you have the field open, you only have that one card/note selected.

When you search up that set of notes/cards, _select all of them_, open Find and Replace, paste in that exact same search string as the “Find” and add whatever you want to replace it with, All Fields, limit it to selected notes only and ignore case (but don’t tick regex), and click OK – what does the pop-up in the corner say after that?  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/3X/a/c/ac32e94e4525b629c678cd1ed8cfb3285c6413d4.png)

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [January 7, 2025, 8:26am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/8 "2025-01-07T08:26:03Z")

</div>

The issue is likely minor differences between what’s being shown when editing, and the underlying code, e.g. `<br>` vs `<br />`. Exporting to a text file will reveal the text prior to any normalization caused by editing.

---

<div class="post-metadata">

**Author:** ![Ankiuser7](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/ankiuser7/32/19626_2.png) [@Ankiuser7](https://forums.ankiweb.net/u/Ankiuser7)\
**Post date:** [January 9, 2025, 7:09am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/9 "2025-01-09T07:09:25Z")

</div>

I had the exact same thing yesterday.

Try out this method:

> [@Bug: can't find \<br\>](https://forums.ankiweb.net/t/bug-cant-find-br/54119/10):
>
> Ah I found a way around. Instead of finding and replacing \<br\> i just found and replaced \<br and \> separately which didn’t work in the notes view but now in cards view it worked like you said. Dankeschön yum

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [February 8, 2025, 7:09am UTC](https://forums.ankiweb.net/t/how-to-replace-html-tags-in-note-fields/53800/10 "2025-02-08T07:09:54Z")

</div>

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