let obj = { body: { tagName: 'body', attrs: {}, paired: true, children: [ { tagName: 'div', attrs: {}, paired: true, children: [ { tagName: 'span', attrs: {}, paired: true, children: ['Enter data please:'] }, { tagName: 'br', paired: false }, { tagName: 'input', attrs: { type: 'text', id: 'name' }, paired: false }, { tagName: 'input', attrs: { type: 'text', id: 'surname' }, paired: false } ] }, { tagName: 'div', attrs: {}, paired: true, children: [ { tagName: 'button', attrs: { id: 'ok' }, paired: true, children: ['Ok'] }, { tagName: 'button', attrs: { id: 'cancel' }, paired: true, children: ['Cancel'] }, ], }, ] } } console.log(obj.body.children[0].children[0].children[0]) console.log(obj.body.children[1].children[1].attrs.id) console.log(obj.body.children[0].children[1].tagName)