# apoc.convert.Totree availability on Neo4J 5?

**URL:** <https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448>\
**Category:** Procedures & APOC\
**Tags:** apoc\
**Created:** [January 27, 2025, 10:10am UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448 "2025-01-27T10:10:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![zil.darji](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zil.darji/32/33913_2.png) [@zil.darji](https://community.neo4j.com/u/zil.darji)\
**Post date:** [January 27, 2025, 10:10am UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/1 "2025-01-27T10:10:21Z")

</div>

We were using Neo4j Aura with version 4.4 and now want to migrate our database to version 5. Previously, we used the procedure `apoc.convert.toTree`, but in the migration readiness report, it is marked as deprecated.

After reviewing the documentation for version 5, it states that `apoc.convert.toTree` has been replaced by `apoc.paths.toJsonTree`. However, when we executed the query `CALL apoc.help('toJsonTree');` in the Aura console (version 5), it appears that the procedure is not available.

Can anyone assist with this issue?

---

<div class="post-metadata">

**Author:** ![dana\_canzano](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dana_canzano/32/27392_2.png) [@dana\_canzano](https://community.neo4j.com/u/dana_canzano)\
**Post date:** [January 29, 2025, 2:15pm UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/2 "2025-01-29T14:15:50Z")

</div>

@zil.darji

[https://neo4j.com/docs/aura/classic/platform/apoc/](https://neo4j.com/docs/aura/classic/platform/apoc/) states

```auto
A subset of the APOC Core functions and procedures are pre-installed 
and available in Aura, as shown below:

```

and then lists the functions and procedures available and for which `apoc.paths.toJsonTree` is reported as not available

---

<div class="post-metadata">

**Author:** ![zil.darji](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zil.darji/32/33913_2.png) [@zil.darji](https://community.neo4j.com/u/zil.darji)\
**Post date:** [January 29, 2025, 3:14pm UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/3 "2025-01-29T15:14:31Z")

</div>

Hi @dana_canzano ,  
Yes, the procedure `apoc.paths.toJsonTree` is not mentioned there. Can you please suggest another procedure or solution that I can use for the same purpose?

---

<div class="post-metadata">

**Author:** ![aman.singh](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/aman.singh/32/29204_2.png) [@aman.singh](https://community.neo4j.com/u/aman.singh)\
**Post date:** [January 30, 2025, 8:32am UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/4 "2025-01-30T08:32:56Z")

</div>

Hi @zil.darji we are reviewing `apoc.paths.toJsonTree ` for inclusion into Aura. Unfortunately I don't have a timeline on this yet but will get back to you within the next few days.

---

<div class="post-metadata">

**Author:** ![zil.darji](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zil.darji/32/33913_2.png) [@zil.darji](https://community.neo4j.com/u/zil.darji)\
**Post date:** [January 30, 2025, 10:30am UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/5 "2025-01-30T10:30:22Z")

</div>

Thanks for the answer, Aman.  
I am awaiting hearing back from you.

---

<div class="post-metadata">

**Author:** ![aman.singh](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/aman.singh/32/29204_2.png) [@aman.singh](https://community.neo4j.com/u/aman.singh)\
**Post date:** [January 30, 2025, 3:27pm UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/6 "2025-01-30T15:27:08Z")

</div>

Hi @zil.darji thanks for holding on here. We will include apoc.paths.toJsonTree in the next Neo4j Calendar release in approximately a month's time.

You could also migrate now and carry on using apoc.convert.toTree. It will not be removed until we release Cypher 25, and make sure to change it to apoc.paths.toJsonTree as soon as the next release is available

---

<div class="post-metadata">

**Author:** ![aman.singh](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/aman.singh/32/29204_2.png) [@aman.singh](https://community.neo4j.com/u/aman.singh)\
**Post date:** [February 9, 2025, 1:29pm UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/7 "2025-02-09T13:29:33Z")

</div>

Hi @zil.darji apoc.paths.toJsonTree is now available in Aura.

---

<div class="post-metadata">

**Author:** ![zil.darji](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zil.darji/32/33913_2.png) [@zil.darji](https://community.neo4j.com/u/zil.darji)\
**Post date:** [February 10, 2025, 4:41am UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/8 "2025-02-10T04:41:52Z")

</div>

Yes, @aman.singh We have checked and it's working fine. Thanks

---

<div class="post-metadata">

**Author:** ![zil.darji](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/zil.darji/32/33913_2.png) [@zil.darji](https://community.neo4j.com/u/zil.darji)\
**Post date:** [February 12, 2025, 8:17am UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/9 "2025-02-12T08:17:11Z")

</div>

@aman.singh , We noticed that some response changes there for the same query. Please find the document for old and new queries with their responses.

> Old Query:

```auto
"MATCH (nl:Nl{nl_id:2424})-[:NL_REFERS_TO_SOL]->(sl:Sol)<-[:RULE_BOOK_ISSUE_CONSISTS_OF_SOLS]-(rbi:Rule_Book_Issue)<-[:HAS_RULE_BOOK_ISSUE]-(rb:Rule_Book)
CALL {
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(prb:Rule_Book)-[:HAS_RULE_BOOK_CHILD*]->(rb)
  RETURN path
  UNION
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(rb)
  RETURN path
}
WITH collect(path) AS paths
CALL apoc.convert.toTree(paths) yield value
RETURN value"

```

> Old query Response:

```auto
"[
  {
    ""value"": {
      ""_type"": ""Rule_Book_Struct"",
      ""_id"": 376,
      ""rule_book_struct_id"": ""Rule Root Object"",
      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:376"",
      ""has_rule_book_struct_child"": [
        {
          ""_type"": ""Rule_Book_Struct"",
          ""_id"": 405,
          ""rule_book_struct_id"": ""NAT"",
          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:405"",
          ""has_rule_book_struct_child.order_rule_book_struct"": 30,
          ""has_rule_book_struct_child.order"": 30,
          ""rule_book_struct_active"": true,
          ""has_rule_book_struct_child._id"": 21181,
          ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21181"",
          ""has_rule_book_struct_child"": [
            {
              ""_type"": ""Rule_Book_Struct"",
              ""_id"": 651,
              ""rule_book_struct_id"": ""DE"",
              ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:651"",
              ""has_rule_book_struct_child.order_rule_book_struct"": 20,
              ""has_rule_book_struct_child.order"": 20,
              ""rule_book_struct_active"": true,
              ""has_rule_book_struct_child._id"": 21451,
              ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21451"",
              ""has_rule_book_struct_child"": [
                {
                  ""_type"": ""Rule_Book_Struct"",
                  ""_id"": 803,
                  ""rule_book_struct_id"": ""DE_V"",
                  ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:803"",
                  ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                  ""has_rule_book_struct_child.order"": 20,
                  ""rule_book_struct_active"": true,
                  ""has_rule_book_struct_child._id"": 21587,
                  ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21587"",
                  ""has_rule_book_struct_child"": [
                    {
                      ""_type"": ""Rule_Book_Struct"",
                      ""_id"": 872,
                      ""rule_book_struct_id"": ""DE_V_ORG"",
                      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:872"",
                      ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                      ""has_rule_book_struct_child.order"": 20,
                      ""rule_book_struct_active"": true,
                      ""has_rule_book_struct_child._id"": 21656,
                      ""rule_book_belongs_to_struct"": [
                        {
                          ""rule_book_active"": true,
                          ""_type"": ""Rule_Book"",
                          ""_id"": 5547,
                          ""rule_book_belongs_to_struct.order"": 50,
                          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:5547"",
                          ""rule_book_belongs_to_struct.order_rule_book_in_struct"": 50,
                          ""rule_book_belongs_to_struct._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:24422"",
                          ""rule_book_id"": ""DE_FSAAKV"",
                          ""rule_book_belongs_to_struct._id"": 24422
                        }
                      ],
                      ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21656""
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  }
]"

```

> New Query:

```auto
"MATCH (nl:Nl{nl_id:2424})-[:NL_REFERS_TO_SOL]->(sl:Sol)<-[:RULE_BOOK_ISSUE_CONSISTS_OF_SOLS]-(rbi:Rule_Book_Issue)<-[:HAS_RULE_BOOK_ISSUE]-(rb:Rule_Book)
CALL {
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(prb:Rule_Book)-[:HAS_RULE_BOOK_CHILD*]->(rb)
  RETURN path
  UNION
  WITH rb
  MATCH path = (rbs:Rule_Book_Struct{rule_book_struct_id:""Rule Root Object""})-[:HAS_RULE_BOOK_STRUCT_CHILD*]->(rbsc:Rule_Book_Struct)<-[:RULE_BOOK_BELONGS_TO_STRUCT]-(rb)
  RETURN path
}
WITH collect(path) AS paths
CALL apoc.paths.toJsonTree(paths) yield value
RETURN value"

```

> New Query Response

```auto
"[
  {
    ""value"": {
      ""_type"": ""Rule_Book_Struct"",
      ""_id"": 376,
      ""rule_book_struct_id"": ""Rule Root Object"",
      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:376"",
      ""has_rule_book_struct_child"": [
        {
          ""_type"": ""Rule_Book_Struct"",
          ""_id"": 405,
          ""rule_book_struct_id"": ""NAT"",
          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:405"",
          ""has_rule_book_struct_child.order_rule_book_struct"": 30,
          ""has_rule_book_struct_child.order"": 30,
          ""rule_book_struct_active"": true,
          ""has_rule_book_struct_child._id"": 21181,
          ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21181"",
          ""has_rule_book_struct_child"": [
            {
              ""_type"": ""Rule_Book_Struct"",
              ""_id"": 651,
              ""rule_book_struct_id"": ""DE"",
              ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:651"",
              ""has_rule_book_struct_child.order_rule_book_struct"": 20,
              ""has_rule_book_struct_child.order"": 20,
              ""rule_book_struct_active"": true,
              ""has_rule_book_struct_child._id"": 21451,
              ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21451"",
              ""has_rule_book_struct_child"": [
                {
                  ""_type"": ""Rule_Book_Struct"",
                  ""_id"": 803,
                  ""rule_book_struct_id"": ""DE_V"",
                  ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:803"",
                  ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                  ""has_rule_book_struct_child.order"": 20,
                  ""rule_book_struct_active"": true,
                  ""has_rule_book_struct_child._id"": 21587,
                  ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21587"",
                  ""has_rule_book_struct_child"": [
                    {
                      ""_type"": ""Rule_Book_Struct"",
                      ""_id"": 872,
                      ""rule_book_struct_id"": ""DE_V_ORG"",
                      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:872"",
                      ""has_rule_book_struct_child.order_rule_book_struct"": 20,
                      ""has_rule_book_struct_child.order"": 20,
                      ""rule_book_struct_active"": true,
                      ""has_rule_book_struct_child._id"": 21656,
                      ""has_rule_book_struct_child._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:21656""
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  },
  {
    ""value"": {
      ""rule_book_active"": true,
      ""_type"": ""Rule_Book"",
      ""_id"": 5547,
      ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:5547"",
      ""rule_book_id"": ""DE_FSAAKV"",
      ""rule_book_belongs_to_struct"": [
        {
          ""_type"": ""Rule_Book_Struct"",
          ""_id"": 872,
          ""rule_book_struct_id"": ""DE_V_ORG"",
          ""rule_book_belongs_to_struct.order"": 50,
          ""_elementId"": ""4:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:872"",
          ""rule_book_belongs_to_struct.order_rule_book_in_struct"": 50,
          ""rule_book_belongs_to_struct._elementId"": ""5:b5bcbbcb-1b72-4e27-8ea2-06ab9616303e:24422"",
          ""rule_book_struct_active"": true,
          ""rule_book_belongs_to_struct._id"": 24422
        }
      ]
    }
  }
]"

```

---

<div class="post-metadata">

**Author:** ![larsar](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/larsar/32/34757_2.png) [@larsar](https://community.neo4j.com/u/larsar)\
**Post date:** [April 24, 2025, 11:43am UTC](https://community.neo4j.com/t/apoc-convert-totree-availability-on-neo4j-5/72448/10 "2025-04-24T11:43:01Z")

</div>

I have also changed out the toTree with toJsonTree. And notice that the return value is totally different. ToJsonTree makes multiple trees and only includes the outgoing relationships. Are there any way I can make toJsonTree also include incoming relationships also? (like toTree does)
