---
title: "Effective variable debugging"
url: "https://blog.beyondthecloud.dev/tips/effective-variable-debugging"
category: "Apex"
tags: "debugging"
published: "2024-01-02"
---

# Effective variable debugging

When you use System.debug() to display values of lists or big objects you usually see that the output is truncated:

### Effective variable debugging: avoiding truncation

When you use System.debug() to display values of lists or big objects you usually see that the output is truncated:

```apex
System.debug([SELECT Id, Name FROM Account LIMIT 100]);
```

```bash
10:05:46:011 USER_DEBUG [1]|DEBUG|(Account:{Id=0010Y00001BmjXlQAJ, Name=JP Community Users},
Account:{Id=0010Y00001BqMUMQA3, Name=My Account #1}, Account:{Id=0010Y000016unWHQAY, Name=Customers},
Account:{Id=0010Y000016uofsQAA, Name=CommunityUsers}, Account:{Id=0010Y000016unWnQAI, Name=Partne
```

You can simply use JSON.serializePretty() method to see the full content of debugged variable:

```apex
System.debug(JSON.serializePretty([SELECT Id, Name FROM Account LIMIT 100]));
```

```json
09:05:46.1 (47092646)|USER_DEBUG|[3]|DEBUG|[ {
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v59.0/sobjects/Account/0010Y00001BmjXlQAJ"
  },
  "Id" : "0010Y00001BmjXlQAJ",
  "Name" : "JP Community Users"
}
```
