# Organize AL code with region directives
> APPLIES TO: Business Central 2020 release wave 2 and later
## Organize code into regions
Use the `#region` directive to mark a block of code that you can expand or collapse. Regions can improve readability in large files and help you focus on the code you're currently editing. The `#endregion` directive specifies the end of a `#region` block.
> NOTE
> Add a comment after the `#region` directive to describe the code block, as shown in the following example.
## Syntax
```al
#region [comment]
    code
```
```al
#endregion
```
## Remarks
A `#region` block must be terminated with a `#endregion` directive.
A `#region` block can't overlap with an `#if` block. However, a `#region` block can be nested in an `#if` block, and an `#if` block can be nested in a `#region` block.
## Example
In this example, the `#region` directive makes a code block that is up for refactoring collapsible.
```al
#region Refactoring candidate
    procedure CalculateLegacyValue()
    begin
        // Refactor this implementation.
    end;
#endregion
```
## Related information
Development in AL<../devenv-dev-overview>
AL development environment<../devenv-reference-overview>
Pragma directive in AL<devenv-directive-pragma>
devenv-directives-in-al#conditional-directives
Deprecating explicit and implicit with statements<../devenv-deprecating-with-statements-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/directives/devenv-directive-region, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/directives/devenv-directive-region/
