As in latest release of Angular (v6.1.0) , Angular Team has added new built in pipe for the same named as keyvalue pipe to help you iterate through objects, maps, and arrays, in the common module of angular package. For example -

<div *ngFor="let item of testObject | keyvalue">
    Key: <b>{{item.key}}</b> and Value: <b>{{item.value}}</b>
</div>

To keep original order, use keyvalue:onCompare,
and in component define callback:

// ...
import {KeyValue} from '@angular/common';

@Component(/* ... */)
export class MyComponent {
  private onCompare(_left: KeyValue<any, any>, _right: KeyValue<any, any>): number {
    return -1;
  }
}

Working Forked Example

check it out here for more useful information -

  • https://github.com/angular/angular/blob/master/CHANGELOG.md#features-3
  • https://github.com/angular/angular/commit/2b49bf7

If you are using Angular v5 or below or you want to achieve using pipe follow this answer

  • access key and value of object using ngfor
Answer from Pardeep Jain on Stack Overflow
🌐
Angular University
blog.angular-university.io › angular-2-ngfor
Angular ngFor: Complete Guide
March 8, 2025 - Tracking by object identity is a good default strategy because Angular has no information about the object so it cannot tell which property it should use for tracking. As we see, ngFor already does a lot of optimizations out-of-the-box to try to reuse existing DOM elements as much as possible, but it's doing so based on object identity.
Discussions

How to read [object object] using *ngFor in angular2
I want to iterate [object object] using *ngFor in angular2, the problem is the object is not array of object but object of object which contains further objects · I know we can use pipe to iterate the object but how we can iterate further from object to object means data->picture->thum:url ... More on forum.ionicframework.com
🌐 forum.ionicframework.com
0
0
December 30, 2016
How to loop over object properties with ngFor in Angular
this is post is about an interesting problem I found at work. If you don’t know it yet. I’m talking about Angular 2+ The problem So you want to display the markup for a list, the values for this... More on stackoverflow.com
🌐 stackoverflow.com
angular - How to iterate object keys using *ngFor - Stack Overflow
I want to iterate [object object] using *ngFor in Angular 2. More on stackoverflow.com
🌐 stackoverflow.com
August 25, 2017
How do you use ngFor to go over nested objects? Stackoverflow answers are just not cutting it!
When debugging issues like this, the json pipe is your best friend. Using that, you can see that the keyvalue pipe makes the object take the shape of {'key': string; 'value': T}. You need to use response.value.label and response.value.amount. Here is a working stackblitz . More on reddit.com
🌐 r/Angular2
5
6
November 24, 2021
🌐
Medium
medium.com › @papaponmx › looping-over-object-properties-with-ngfor-in-angular-869cd7b2ddcc
Looping over object properties with ngFor in Angular | by Jaime | Medium
November 11, 2018 - Step 1. Get all the object keys. using Object.keys. This method returns an array of a given object’s own enumerable properties. Step 2. Create an empty array. This is an where all the properties are going to live, since your new ngFor loop is going to point to this array, we gotta catch them all.
🌐
DEV Community
dev.to › sandeepbalachandran › how-to-loop-through-object-properties-with-ngfor-in-angular-59e8
How to loop through object properties with ngFor in angular - DEV Community
June 28, 2020 - You can use the keyvalue pipe to split the object into key/value pairs where the key is property name (skill, education, experience) and the value is the object (name, start_date...) *ngFor="let property of object | keyvalue" {{property.key}}: {{property.value.name}}
🌐
Ionic Framework
forum.ionicframework.com › ionic framework › ionic-v3
How to read [object object] using *ngFor in angular2 - ionic-v3 - Ionic Forum
December 30, 2016 - I want to iterate [object object] using *ngFor in angular2, the problem is the object is not array of object but object of object which contains further objects. { <-- this is an array of object "data": { "id": …
🌐
Angular Wiki
angularjswiki.com › angular › angular-keyvalue-pipe-loop-object-key-values-using-ngfor
Loop Object Key Values In Angular Using *NgFor & Angular Keyvalue Pipe | Angular Wiki
KeyValue pipe released in Angular 6.1 to loop through objects,Maps and arrays.Now by passing KeyValue pipe to *ngFor we can loop through objects key values
🌐
GeeksforGeeks
geeksforgeeks.org › angularjs › how-to-loop-through-object-with-ngfor-in-angular
How to Loop through Object with *ngFor in Angular ? - GeeksforGeeks
July 23, 2025 - Example: This is another example that illustrates iterating over them using ngFor in Angular. ... <!-- app.component.html --> <h2 style="color: green">GeeksforGeeks</h2> <h2>Loop through Object with *ngFor </h2> <li *ngFor="let key of keys()">{{key}}:{{states[key]}}</li>
Find elsewhere
🌐
Malcoded
malcoded.com › posts › angular-ngfor
Angular NgFor: Everything you need to know | malcoded.com
Unfortunately, we can’t just use objects with ngFor. But it is not impossible to do. To make objects compatible with ngFor, we need to convert the object to an array. Easy right? But how can we do so in a convenient way?
🌐
Angular
v17.angular.io › tutorial › first-app › first-app-lesson-08
Lesson 8: Use *ngFor to list objects in component
Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
🌐
Angular
angular.dev › api › common › NgFor
NgFor • Angular
Even if the data hasn't changed, the second response produces objects with different identities, and Angular must tear down the entire DOM and rebuild it (as if all old elements were deleted and all new elements inserted). To avoid this expensive operation, you can customize the default tracking algorithm. by supplying the trackBy option to NgForOf.
Top answer
1 of 10
210

Angular 6.0.0

https://github.com/angular/angular/blob/master/CHANGELOG.md#610-2018-07-25

introduced a KeyValuePipe

See also https://angular.io/api/common/KeyValuePipe

@Component({
  selector: 'keyvalue-pipe',
  template: `<span>
    <p>Object</p>
    <div *ngFor="let item of object | keyvalue">
      {{item.key}}:{{item.value}}
    </div>
    <p>Map</p>
    <div *ngFor="let item of map | keyvalue">
      {{item.key}}:{{item.value}}
    </div>
  </span>`
})
export class KeyValuePipeComponent {
  object: {[key: number]: string} = {2: 'foo', 1: 'bar'};
  map = new Map([[2, 'foo'], [1, 'bar']]);
}

original

You can use a pipe

@Pipe({ name: 'keys',  pure: false })
export class KeysPipe implements PipeTransform {
    transform(value: any, args: any[] = null): any {
        return Object.keys(value)//.map(key => value[key]);
    }
}
<div *ngFor="let key of objs | keys">

See also How to iterate object keys using *ngFor?

2 of 10
59

I think the most elegant way to do that is to use the javascript Object.keys like this (I had first implemented a pipe for that but for me, it just complicated my work unnecessary):

in the Component pass Object to template:

Object = Object;

then in the template:

<div *ngFor="let key of Object.keys(objs)">
   my key: {{key}}
   my object {{objs[key] | json}} <!-- hier I could use ngFor again with Object.keys(objs[key]) -->
</div>

If you have a lot of subobjects you should create a component that will print the object for you. By printing the values and keys as you want and on an subobject calling itselfe recursively.

Hier you can find an stackblitz demo for both methods.

🌐
Readerstacks
readerstacks.com › home › ngfor and for loop over object or array in angular
ngFor and For loop used for Angular Iterate Over Object
October 4, 2022 - Loops are used to iterate through objects or array, In angular we can use ngFor and For loop over array or object in angular, ngFor is a template structural directive which is used to iterate a loop in template file whereas for and each is used ...
🌐
Reddit
reddit.com › r/angular2 › how do you use ngfor to go over nested objects? stackoverflow answers are just not cutting it!
r/Angular2 on Reddit: How do you use ngFor to go over nested objects? Stackoverflow answers are just not cutting it!
November 24, 2021 -

Hi everyone, newbie to angular and I am having some trouble getting all my values in html from an object. The following is stored in results: {}

{
    "term": {
        "amount": 36,
        "label": "Term"
    },
    "firstPayment": {
        "amount": 421.88,
        "label": "First Payment"
    },
}

I would like to then output it in a list like this:

<div *ngFor="NOTHING HERE WORKS">

<ul class="list-group" > <li > <div > <span >{{LABEL VALUE TO GO HERE}}</span> </div> <div> <span>{{AMOUNT VALUE TO GO HERE}}</span> </div> </li> </ul> </div>

since its nested *ngFor="let result of results | keyvalue "> doesn't work, and all the suggestions on stackoverflow also dont work :/

🌐
Medium
medium.com › typescript-center › angular-tips-iterating-over-object-properties-using-ngfor-c04ce829c
Angular Tips: Iterating Over Object Properties using *ngFor | by Dávid Sipos | Typescript Center
August 10, 2023 - In this article, we'll explore how to use *ngFor to access both the keys and values of an object within your Angular templates.
🌐
Techaltum
tutorial.techaltum.com › ngFor-in-angular.html
ngFor in Angular | @for angular 17 | For loop in angular
Angular 17 introduced @for block to iterate over iterators instead of ngFor directive. @for can iterate Array, JSON ,strings, but not objects as objects are not iterators in javascript.
🌐
GeeksforGeeks
geeksforgeeks.org › angularjs › how-to-iterate-over-object-in-angular
How to iterate over Object in Angular ? - GeeksforGeeks
July 23, 2025 - Example: This example illustrates the iteration over the object in Angular using Object.keys() Method.
🌐
sqlpey
sqlpey.com › angular › angular-object-iteration-ngfor
Angular Object Iteration: Accessing Keys and Values in ngFor …
July 25, 2025 - For Angular versions 6.1.0 and above, the framework provides a built-in keyvalue pipe. This pipe is specifically designed to iterate over objects, maps, and arrays, making it a clean and efficient solution. To maintain the original order of the object’s properties, you can provide a comparison function. ... <div *ngFor="let item of testObject | keyvalue"> Key: <b>{{item.key}}</b> and Value: <b>{{item.value}}</b> </div>